<?php $url = ''; $cont = file_get_contents($url); //打印出match $data = getimgs($cont); foreach ($data as $k => $v) { echo "<img src='".$v."' alt=''>"; echo '<br>'; } function getimgs($str) { $reg = '/((http|https):\/\/)+(\w+\.)+(\w+)[\w\/\.\-]*(jpg|gif|png)/'; $matches = array(); preg_match_all($reg, $str, $matches); foreach ($matches[0] as $value) { $data[] = $value; } return $data; }
友情提示:垃圾评论一律封号...