Cyto Posted November 27, 2011 Share Posted November 27, 2011 Hi, Can someone check wye this gives a empty array: $url = "http://www.someurl.com"; $file = file_get_contents($url); $preg = '<a href='."'(.*)'".'><span class=window2 style="text-transform: capitalize">(.*)<\/span><br \/> [(.*)]<\/a>'; preg_match_all('/'.$preg.'/i', $file, $m); //name print_r($m); Output: Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) ) I am trying to find a name link in a,span from another site, but gives me a empty array. Can someone help? thanks, Cyto Quote Link to comment Share on other sites More sharing options...
xyph Posted November 28, 2011 Share Posted November 28, 2011 My guess is the RegEx isn't matching. It's impossible to check this because there's no content to test against. You really should parse the content using the DOMDocument class though. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 29, 2011 Share Posted November 29, 2011 []s are special characters in regular expressions. They need to be escaped if you want them literally. Quote Link to comment Share on other sites More sharing options...
.josh Posted November 29, 2011 Share Posted November 29, 2011 Also you're probably going to run into trouble with those greedy quantifiers... Quote Link to comment Share on other sites More sharing options...
Cyto Posted November 30, 2011 Author Share Posted November 30, 2011 k thx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.