我有这个代码,它应该获取数据并按表格排列 主页 |平局 |AWAY,当您查看代码时,您会发现 count 变量被分配了一个静态变量,当获取的值数量大于分配的变量时,它会带来问题,所以我需要的帮助是我将如何确定或我将使用什么函数来计算此属性的元素数量
'div[data-gamename="1X2"'
如下面的代码所示,如何计算它们?
<?php
include('advanced_html_dom.php');
$html = file_get_html('your-url-here');
//Here is where should be a counter to be assigned to $count variable
$count = 450;
for ($i=0; $i<$count; $i+=3){
$dot = $html->find('div[data-gamename="1X2"]',$i);
echo " Home ".$dot."<br>";
}
//This codes will be re-written to look same like the above
//I left for reference so you can get picture what i mean
$dot2 = $html->find('div[data-gamename="1X2"]',1);
$dot3 = $html->find('div[data-gamename="1X2"]',2);
echo "Draw ".$dot2."<br>";
echo "Away ".$dot3."<br>";
$html->clear();
?>
知道如何实现这一点吗?
$numcounter = count($dot2 = $html->find('div[data-gamename="1X2"]'));
echo "Number of elements are ".$numcounter." ------";
这是供将来参考的答案。$numcounter
变量应该分配给$count
变量,从上面的代码来看,它应该是这样的$count = $numcounter;