Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>First Solution using just PHP</h2> <p>I don't know how you grab the tweets, but I used this PHP-code before and it prints out links right away wrapped in <code>&lt;a&gt;</code>-tags. So, no need to use JavaScript here:</p> <pre><code>// get tweets function UtilityGetLatestTweets() { $user = 'username'; $limit = 10; $value = ''; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://search.twitter.com/search.atom?q=from:' . $user . '&amp;amp;rpp=' . $limit); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, 0); $result = curl_exec($curl); curl_close($curl); $xml = simplexml_load_string($result); foreach ($xml-&gt;entry as $tweet) { $value .= $tweet-&gt;content; } return $value; } $tweets = UtilityGetLatestTweets(); </code></pre> <p>Maybe this helps you.</p> <h2>Edit: Second Solution using JavaScript</h2> <p>If you want an JavaScript-solution, you can go with this:</p> <h3>JavaScript</h3> <pre><code>function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/ig; return text.replace(exp,"&lt;a href='$1'&gt;$1&lt;/a&gt;"); } // when document is loaded $(document).ready(function () { // select all p-tags within a container $('#content p').each( function (key, value) { // replace the content $(value).html( replaceURLWithHTMLLinks($(value).text()) ); }); }); </code></pre> <h3>HTML</h3> <pre><code>&lt;div id="content"&gt; &lt;p&gt;Some text and link http://somethingsomething.com&lt;/p&gt; &lt;p&gt;Some text and link http://somethingdifferent.com&lt;/p&gt; &lt;/div&gt; </code></pre> <p>This assumes that all <code>&lt;p&gt;</code>-tags are wrapped within a container with an ID.</p> <ul> <li>it uses the <strong>ID-selector</strong> in combination with the <strong>tag-selector</strong>: `$('#content p') to select all tweets</li> <li>afterwards it loops through all elements: <ul> <li>it gets the text from each entry using <code>$(value).text()</code></li> <li>replaces the anchors using the <code>replaceURLWithHTMLLinks</code> from this <a href="https://stackoverflow.com/a/37687/1456376">answer</a></li> <li>updates the HTML of the <code>&lt;p&gt;</code>-tag using <code>$(value).html()</code></li> </ul></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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