php通过正则从字符串中获取所有图片url地址

/**
 * 提取字符串中图片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;
}

  

posted @ 2014-03-11 23:29  fighter  阅读(10958)  评论(1编辑  收藏  举报