Ineed to extract images from html page using regular expression, but am not able to get desired result.
help me.
Bellow is my code
[PHP]<?php
$site='http://www.gmail.com';
$str_text = file_get_conten ts($site);
function str_img_src($ht ml) {
if (strpos($html, '<img') !== false) {
$imgsrc_regex = '#<\s*img [^\>]*src\s*=\s*(["\'])(.*?)\1#im';
preg_match($img src_regex, $html, $matches);
unset($imgsrc_r egex);
unset($html);
if (is_array($matc hes) && !empty($matches )) {
return $matches;
} else {
return false;
}
} else {
return false;
}
}
$ms=str_img_src ($str_text);
foreach($ms as $m) {
echo $m;
}
[/PHP]
help me.
Bellow is my code
[PHP]<?php
$site='http://www.gmail.com';
$str_text = file_get_conten ts($site);
function str_img_src($ht ml) {
if (strpos($html, '<img') !== false) {
$imgsrc_regex = '#<\s*img [^\>]*src\s*=\s*(["\'])(.*?)\1#im';
preg_match($img src_regex, $html, $matches);
unset($imgsrc_r egex);
unset($html);
if (is_array($matc hes) && !empty($matches )) {
return $matches;
} else {
return false;
}
} else {
return false;
}
}
$ms=str_img_src ($str_text);
foreach($ms as $m) {
echo $m;
}
[/PHP]
Comment