Last active
December 29, 2015 00:19
-
-
Save PhilKershaw/7585656 to your computer and use it in GitHub Desktop.
Wrap URLs in tweets in a tags.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private static function _applyEntities(&$feed) | |
{ | |
if (null !== $feed) { | |
foreach($feed as &$item) { | |
if (null !== $item['entities']['urls']) { | |
$urls = array_reverse($item['entities']['urls']); | |
$content = &$item['text']; | |
foreach ($urls as $url) { | |
$content = substr_replace($content, '</a>', $url['indices'][1], 0); | |
$content = substr_replace($content, '<a href="'.$url['url'].'">', $url['indices'][0], 0); | |
} | |
unset($content); | |
} | |
} | |
unset($item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment