Match code on another domain


I have the following code for matching a pattern on another domain. But it does not seem to work.

$url = ‘’;
$haystack = file_get_contents($url);

$content = “This function does the opposite of explode() function. Explode divides a string into array of strings on a separator, this one joins an array of strings with a separator to form a string. join() and implode() functions are identical.<a href=‘’ title=‘’><img alt=‘’ border=‘0’ height=‘15’ src=‘’ width=‘80’/></a>It can be used to find a string or character (needle) within another string (haystack). If match is found, the function returns a substring of haystack from ‘needle’ onwards. It returns false if no match is found.”;

if (preg_match_all(“{<a href=\‘http:\/\/\’ title=\‘\’><img[^>]alt=\‘\’ border=\‘0\’ height=\‘15\’ src=\‘http:\/\/\’ width=\‘80\’/></a>}”, $haystack, $matches)) {
echo “Match was found <br />”;
echo $matches[0];
echo “Match was not found”;

If i use the $content variable then it identifies properly but when I use another website where same code exists then it does not identify correctly. It shows match not found irrespective of whether the code exists or not.

Please someone help me find a solution for this issue. I had put this question in this forum earlier also but I din’t get a satisfactory answer.

Have you confirmed that $content is within $haystack?

You can echo (or var_dump) the contents of $haystack, use strpos to find out where $content is within $haystack, and if it’s not found, gradually reduce $content until you discover what is interfering with the match.

Once you know what’s interfering with the match, then that info can be applied to the pattern match too.