php正则匹配img中src

/**
 * 在富文本编辑器中 获得图片  返回全路径数组
 */
function getContentImg($content){
    $preg =  '//i';
    preg_match_all($preg, $content, $match);
    $count = count($match[1]);
    $filepaths = '';
    if ($count > 0) {
        for ($i = 0; $i < $count; $i++) {
            if ($i != $count - 1) {
                $filepaths .= $match[1][$i] . ',';
            } else {
                $filepaths .= $match[1][$i];
            }
        }
    }
    return $filepaths;
}

你可能感兴趣的:(php正则匹配img中src)