Jump to content

How To Use This Reg_Ex Example


medicalboy

Recommended Posts

this is a code to get all images from a certain site, i want to know how to echo output correctly

$images = array();preg_match_all('/(img|src)\=(\"|\')[^\"\'\>]+/i', $data, $media);unset($data);$data=preg_replace('/(img|src)(\"|\'|\=\"|\=\')(.*)/i',"$3",$media[0]);foreach($data as $url){$info = pathinfo($url);if (isset($info['extension'])){  if (($info['extension'] == 'jpg') ||  ($info['extension'] == 'jpeg') ||  ($info['extension'] == 'gif') ||  ($info['extension'] == 'png'))  array_push($images, $url);}}

Link to comment
Share on other sites

$data in the first instance (preg_match_all) should be the markup containing the images (ie page source). media is where it will be returned. I think you mistakenly swapped those around in the described function? however after quickly looking at the code, you could doecho $url; inside the foreach function.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...