php foreach项目总数
使用php简单dom解析器,我有一个项目列表,我想计算结果中有多少个项目。 如果我有15个项目,我想显示总数为15php foreach项目总数,php,Php,使用php简单dom解析器,我有一个项目列表,我想计算结果中有多少个项目。 如果我有15个项目,我想显示总数为15 <?php include('simple_html_dom.php'); $search = $_GET['search']; $html = file_get_html('http://mysite/'.$search.'.html'); foreach ( $html->find('div#song_html ') as $e ) { $title=
<?php
include('simple_html_dom.php');
$search = $_GET['search'];
$html = file_get_html('http://mysite/'.$search.'.html');
foreach ( $html->find('div#song_html ') as $e ) {
$title= $e->find('div', 2)->plaintext;
$total= //????? How can i Get total number of item????
echo $title.'<br>';
echo $total.'<br>';
}
?>
尝试:
嗨,你的第一个答案很好$总计=计数$html->查找'divsong_html';换一下我会问你的答案对不起,我不确定你要数数的物品。刚换回来。
$total = count($html->find('div#song_html '));