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

  • Home
  • SEARCH
  • 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 5984789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:25:49+00:00 2026-05-22T22:25:49+00:00

hey guys Im building a script by which Im attempting to find specific links

  • 0

hey guys Im building a script by which Im attempting to find specific links in twitter text results

This script basically checks whether the text contains a url, then determines if that url is one of 6 specific urls, and if it matches outputs the original text into a new array Ive labeled as $imgtweets

the problem however is that despite the fact that I have about 4 text string in the array only one of them is matching and being returned in the $imgtweets array, Im having a hard time determining where Ive made the mistake, any help would go a long way!

this is my code, Ive had to make the array slightly smaller however because im not allowed to post more that 2 hyperlinks at this point:

<?php

$tweets = array(
         "Photo: therulesofagentleman: http://tumblr.com/xc52sgx6u7",
         "http://mypict.me/iysEX So this is Karly. Karly say hello to the world. We've been at this a while when your fans (cont)",
         "this is some test text that doesnt contain any links for testing purposes");

         $imgtweets = array();

         foreach($tweets as $tweet) {
         preg_match_all("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", $tweet, $matches, PREG_PATTERN_ORDER);

         $tweetlinks = $matches[0];
         if (!empty($tweetlinks)){

         foreach($tweetlinks as $key => $link) {

         if (substr($link,0,14)=="http://lockerz" || substr($link,0,12)=="http://yfrog"
         || substr($link,0,14)=="http://twitpic" || substr($link,0,13)=="http://tumblr"
         || substr($link,0,13)=="http://mypict" || substr($link,0,14)=="http://instagr"  )
         {
          array_push($imgtweets,"$tweet");
          }
       }
      }
     }
       print_r($imgtweets);

?>  
  • 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-05-22T22:25:50+00:00Added an answer on May 22, 2026 at 10:25 pm

    basically you can replace all your code with something like

    $hosts  = "lockerz|yfrog|twitpic|etc";
    $regexp = "~http://($hosts)~";
    
    $img_tweets = preg_grep($regexp, $all_tweets);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, m building a web-page in that theres a tag which holds some
Hey guys, I'm building an application which requires access to the server time before
Hey guys i wrote a quick test. I want delete to call deleteMe which
Hey Guys, building a site and I've got two questions for you. The site
Hey guys. I'm building a simple blog and have my data returning from my
Hey guys, im building a small product catalog for a client. I am currently
Hey guys - I know this is not a strictly programming question but I'm
Hey guys, I've been bashing my head around for hours now, over this login
Hey guys I got a vps which run solusVM. I'm now trying to install
Hey guys, Im building a fairly large website here, I am using quite a

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.