medicalboy Posted October 13, 2011 Share Posted October 13, 2011 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 More sharing options...
shanet Posted October 13, 2011 Share Posted October 13, 2011 $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 More sharing options...
medicalboy Posted October 13, 2011 Author Share Posted October 13, 2011 thanks shanet for ur replyi didn't code this code,am just found it in the web and echo $url isn't related to echo output, the problem in the $media that will store the output ,but i tried it with indexing array,but in vain Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.