php 正则获取文章中的图片路径

/**
 * 提取body中的img-url
 * @param string $body
 * @return array 路径数组
 */
function getBodyImgs($body=''){
  preg_match_all("/<img([^>]*)\s*src=('|\")([^'\"]+)('|\")/i",$body,$match);
  return is_array($match[3])?$match[3]:array();
}

posted on 2022-09-09 08:23  小馬過河﹎  阅读(56)  评论(0)    收藏  举报

导航