任何人都可以帮助测试此代码并告诉我错误是什么? 预期的结果是01223658060102111111
。但它是重复这样的为什么数组结果是重复的?
01223658060102111111012236580601021111110122365806010211111101223658060102111111
这里是我的代码
<?php
ini_set('user_agent', 'My-Application/2.5'); //without this file_get_content would not work
$saveURL = fopen("url.txt", "w");
$html = file_get_contents("http://www.carlist.my/used-cars/2592832/2004-toyota-camry-2-0.html");
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$cont = $xpath->evaluate("//ul[contains(@class, 'list-contact')]/li");
foreach($cont as $con){
echo $con->nodeValue;
}
尝试'回声$ CON组>的nodeValue “
”',看看你在你的foreach循环回声实际上是。运行3次 –
在回声后使用'unset($ con)' –
为什么你需要'foreach'? – jitendrapurohit