Are you working on a url scraping project? Here is a quick way to extract urls from string using preg_match in php. Very simple. You can incorporate it into a function, etc if(preg_match("/[a-z]+:\/\/\S+/",$article,$matches)){ foreach($matches as $url){ echo $url; Once you have the $url variable you can create a MYSQL SELECT statement to inject into your tables