扫码关注官方订阅号
php怎么统计 post-content 内的img数量,并且输出数量,如上面代码,img数量是3
学习是最好的投资!
用preg_match_all正则匹配行么?
preg_match_all
$text = '<p class="post-content"><img src="" /><img src="" /></p>'; $preg = "/(\<img.*?\/\>)/s"; echo preg_match_all($preg, $text, $match);
为什么不用jQuery呢 $('.post-content img').length();
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
用
preg_match_all正则匹配行么?为什么不用jQuery呢
$('.post-content img').length();