我正在创建一个废弃代码,废弃特定郊区的每个地址。但我坚持这个问题; "使用未定义的常数j - 假设' j'"它在$ target_url中确定了任何人都可以帮我解决这个问题吗?
$arr = array("Illawong 2232",
"Strathfield 2135",
"Croydon 2132",
"Croydon Park 2133",
"Burwood 2134",
"Parramatta 2150",
"Hurtsville 2220",
"Seven Hills 2153",
"Blacktown 2148",
"Toongabie 2146",
"Winston Hills 2153",
"Bondi Beach 2026",
"Bondi Junction 2022",
"Coogee 2034",
"Pymble 2073",
"Miranda 2228",
"Caringbah 2229",
"Sylvania 2224",
"Drummoyne 2047",
"Concord 2137"
);
$counter = count($arr);
for($j=0;$j<$counter; $j++)
{
$arr2 = array("list-1", "list-2", "list-3","list-4", "list-5");
$count = count($arr2);
for($i=0;$count>$i;$i++)
{
//scrapping starts here
$target_url = "http://www.xxxxxxxxx.com.au/buy/".$arr[j]."/".$arr2[i]."?includeSurrounding=false";
$html = new simple_html_dom();
$html->load_file($target_url);
foreach($html->find('a[class=name]') as $vcard)
{
echo $vcard. "<br/>"
}
}
}
答案 0 :(得分:1)
很明显,你不用C编程.PHP的变量以let body = new FormData();
body.append('name', 'Test');
this.http.post(<url>,body);
符号开头。如果没有美元符号,则将它们视为常量。
$
应为$arr[j]
,$arr[$j]
应为$arr2[i]
。
答案 1 :(得分:1)
使用此 - 您使用的是没有$符号的变量,这就是为什么它被视为字符串&#39; j&#39;
<?php
$arr = array("Illawong 2232",
"Strathfield 2135",
"Croydon 2132",
"Croydon Park 2133",
"Burwood 2134",
"Parramatta 2150",
"Hurtsville 2220",
"Seven Hills 2153",
"Blacktown 2148",
"Toongabie 2146",
"Winston Hills 2153",
"Bondi Beach 2026",
"Bondi Junction 2022",
"Coogee 2034",
"Pymble 2073",
"Miranda 2228",
"Caringbah 2229",
"Sylvania 2224",
"Drummoyne 2047",
"Concord 2137"
);
$counter = count($arr);
for($j=0;$j<$counter; $j++)
{
$arr2 = array("list-1", "list-2", "list-3","list-4", "list-5");
$count = count($arr2);
for($i=0;$count>$i;$i++)
{
//scrapping starts here
$target_url = "http://www.xxxxxxxxx.com.au/buy/".$arr[$j]."/".$arr2[$i]."?includeSurrounding=false";
$html = new simple_html_dom();
$html->load_file($target_url);
foreach($html->find('a[class=name]') as $vcard)
{
echo $vcard. "<br/>"
}
}
}
答案 2 :(得分:1)
当您使用variables
时,您需要在它们之前使用$
符号,否则您将收到未定义常量的错误,因此请在此处更改
$target_url = "http://www.xxxxxxxxx.com.au/buy/".$arr[$j]."/".$arr2[$i]."?includeSurrounding=false";
//^here //^here