Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok so I needed to do exactly this and I solved it. Here is the function I wrote. <a href="https://gist.github.com/3337428" rel="noreferrer">https://gist.github.com/3337428</a></p> <pre><code>function parse_message( &amp;$tweet ) { if ( !empty($tweet['entities']) ) { $replace_index = array(); $append = array(); $text = $tweet['text']; foreach ($tweet['entities'] as $area =&gt; $items) { $prefix = false; $display = false; switch ( $area ) { case 'hashtags': $find = 'text'; $prefix = '#'; $url = 'https://twitter.com/search/?src=hash&amp;q=%23'; break; case 'user_mentions': $find = 'screen_name'; $prefix = '@'; $url = 'https://twitter.com/'; break; case 'media': $display = 'media_url_https'; $href = 'media_url_https'; $size = 'small'; break; case 'urls': $find = 'url'; $display = 'display_url'; $url = "expanded_url"; break; default: break; } foreach ($items as $item) { if ( $area == 'media' ) { // We can display images at the end of the tweet but sizing needs to added all the way to the top. // $append[$item-&gt;$display] = "&lt;img src=\"{$item-&gt;$href}:$size\" /&gt;"; }else{ $msg = $display ? $prefix.$item-&gt;$display : $prefix.$item-&gt;$find; $replace = $prefix.$item-&gt;$find; $href = isset($item-&gt;$url) ? $item-&gt;$url : $url; if (!(strpos($href, 'http') === 0)) $href = "http://".$href; if ( $prefix ) $href .= $item-&gt;$find; $with = "&lt;a href=\"$href\"&gt;$msg&lt;/a&gt;"; $replace_index[$replace] = $with; } } } foreach ($replace_index as $replace =&gt; $with) $tweet['text'] = str_replace($replace,$with,$tweet['text']); foreach ($append as $add) $tweet['text'] .= $add; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload