简体   繁体   中英

PHP count all images on article

how should I count all images that are displayed in article?

I have array which calls $article and I call article text by $article['article_text'] . For find first image on array I use

$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $article['article_text'], $matches);
$first_img = $matches [1] [0];

but how should I take all images from the article and put them into array for count?

假设您的表达式正确,则可以简单地使用$num_images = count($matches[1]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM