Typecho 猎取文章图片数目代码
做模板有些可能要显现一下文章下图片的数目,这就须要下面的代码了
/* * 猎取图片数目 * @since 2016.07.01 **/function hui_post_imgNum($content){ $output = preg_match_all("/<img.?src="(.?)"1*>/i", $content,$matches); $cnt = count( $matches[1] ); return $cnt;}挪用要领:
<?php echo ''.hui_post_imgNum($this->content).'' ; ?>重要道理就是正则来猎取图片推断几个图片

评论列表