dmarquard Posted April 29, 2008 Share Posted April 29, 2008 I can't seem to find any functions on php.net that can achieve this, so my guess is that it will require an assortment of functions or regular expressions. Basically, I need to first search for the resulting code you'll see below, and then grab ONLY the URL contained in the following code and assign it the $result variable. <h3 id="title"> <a href="http://www.sendmeto.com/a/string/" rel="dc:source" property="dc:title" target="_blank"> The above snippet comes from a webpage with much more source code, but I think I provided enough to go on. Link to comment https://forums.phpfreaks.com/topic/103403-solved-result-of-a-search-to-a-string/ Share on other sites More sharing options...
rhodesa Posted April 29, 2008 Share Posted April 29, 2008 <?php $code = '<h3 id="title"> <a href="http://www.sendmeto.com/a/string/" rel="dc:source" property="dc:title" target="_blank">'; if(preg_match('/<h3 id="title">\s+<a href="(.+?)"/',$code,$matches)){ $result = $matches[1]; print $result; }else{ print "No Match"; } ?> Link to comment https://forums.phpfreaks.com/topic/103403-solved-result-of-a-search-to-a-string/#findComment-529518 Share on other sites More sharing options...
dmarquard Posted April 29, 2008 Author Share Posted April 29, 2008 rhodesa, I can't thank you enough. Your code worked like a charm! Thanks again! Link to comment https://forums.phpfreaks.com/topic/103403-solved-result-of-a-search-to-a-string/#findComment-529519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.