如何统计文章中显示的所有图片?
我有一个数组,它调用$article,我通过$article['article_text']调用文章文本。对于在数组上查找第一个图像,我使用
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $article['article_text'], $matches);
$first_img = $matches [1] [0];但是,我应该如何从文章中获取所有图像,并将它们放入数组中进行计数?
发布于 2013-06-18 20:16:06
假设您的表达式是正确的,您可以简单地使用$num_images = count($matches[1]);
https://stackoverflow.com/questions/17168545
复制相似问题