Can't get preg_match_all working First I use curl to get the source $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $src = curl_exec ($ch); curl_close ($ch); $src = ereg_replace("\n", "", $src); $find = '/<img src="*._50_50_.*"/'; preg_match_all($find, $src, $m); $img=$m[1][0]; Code (markup): Any suggestions??
$find = '/<img src="([a-zA-Z0-9\/\_\-\.]+)_50_50_([a-zA-Z0-9\/\_\-\.]+)"/'; preg_match_all($find, $src, $m); print_r ( $m ); Code (markup):
thx guitarFix, But I don't have the img src yet. I got more than with my code, now it returns Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) ) I tested with print_r ( $m ); $img=$m[1][0]; echo "test ".$m[0][2]; echo $m[0][0]; echo $m[0][1]; echo $m[1][1]; Code (markup): With no luck, Still learning preg_match_all.
ok found a solution $find = '/([\:a-zA-Z0-9\/\_\-\.]+)_50_50_([a-zA-Z0-9\/\_\-\.]+)"/'; preg_match_all($find, $src, $m); //print_r ( $m ); $img=$m[1][0]; $img.="_50_50_"; $img.=$m[2][0]; echo $img;//testing $msg .= '<img src="'.$img.'">'; echo $msg; Code (markup): I added \: and read the array $m. About the array $m is this the right way???