例子1 获取字符串中所有图片
结果显示:
array
(
[0] => array
(
[0] =>
)
[1] => array
(
[0] => upfiles/2009/07/1246430143_1.jpg
)
)
盒例子2,这个函数是提取站外以http,https
/**
* 提取字符串中图片url地址
* @param type $str
* @return type
*/
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[] = get_file($value);
}
return $data;
}
