Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8407413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:21:28+00:00 2026-06-09T23:21:28+00:00

I’ve got another question, although I reckon this one might be a little less

  • 0

I’ve got another question, although I reckon this one might be a little less mundane. But quick disclaimer, this one’s a little more open-ended, so let me start by saying that I am NOT looking for a complete solution to the greater problem I’m opening here, and I apologise in advance if I’m stretching the limit of acceptable minimums of reference code inclusion. I respect your time, plus I prefer to put the pieces together myself 😛

With that out fo the way, here’s the question:
I’ve set up a PHP function that pulls the text from a Twitter feed and then publishes it as a sort of ‘social media’ sidebar on a website. Trouble is, the links that are included in the Tweets are being reproduced as simple text. Example:

    <p>Last night saw the USA win gold in Women's Beach Volleyball---today at 1pm... the
    USA WOMEN SOCCER team will go... http://t.co/M7rtaZFC</p>

I’d like to grab that unlinked URL at the end there, wrap it in some friendly ‘a’ tags, and send it on its merry way.
I can figure out just about everything except actually filtering a jQuery return to target ‘http://&#8217; + the rest of the string.

Is this possible using jQuery? Again, I don’t expect anything too in-depth, just looking for someone to point me in the right direction. Thank you for your time!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:21:30+00:00Added an answer on June 9, 2026 at 11:21 pm

    First Solution using just PHP

    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 <a>-tags. So, no need to use JavaScript here:

    // 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;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->entry as $tweet) {   
            $value .= $tweet->content; 
        }
    
        return $value;
    }
    
    $tweets     = UtilityGetLatestTweets();
    

    Maybe this helps you.

    Edit: Second Solution using JavaScript

    If you want an JavaScript-solution, you can go with this:

    JavaScript

    function replaceURLWithHTMLLinks(text) {
        var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
        return text.replace(exp,"<a href='$1'>$1</a>"); 
    }
    
    // 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()) );
        });
    });
    

    HTML

    <div id="content">
        <p>Some text and link http://somethingsomething.com</p> 
        <p>Some text and link http://somethingdifferent.com</p>
    </div>
    

    This assumes that all <p>-tags are wrapped within a container with an ID.

    • it uses the ID-selector in combination with the tag-selector: `$(‘#content p’) to select all tweets
    • afterwards it loops through all elements:
      • it gets the text from each entry using $(value).text()
      • replaces the anchors using the replaceURLWithHTMLLinks from this answer
      • updates the HTML of the <p>-tag using $(value).html()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.