The code is as follows
foreach ($url as $val) {if ($netbot->fetchlinks ($val)) {$urlarray [] = $netbot->results;} Else{echo "Error:". $netbot->error;exit;}}
This is an array, storing the address
Through the Snoopy method, $netbot->fetchlinks ($val) to get all the link for this URL
So, I want to put all the link in an array
$netbot->results Returns a one-dimensional array
The question now is: $urlarray [] = $netbot->results;
This method assigns a value that gets a multidimensional array
The link in it is only the first time he visited the URL links
I want this $urlarray to be transferred automatically.
When you get the second URL, when you assign a value, you can inherit the subscript above, transforming $urlarray into a 1-dimensional array.
How can this be achieved?
Reply to discussion (solution)
The IF condition inside again cycle?
foreach ($netbot->results as $v) {
$urlarray [] = $v;
}
First, whatever $netbot->results got.
You exit after $netbot->fetchlinks ($val) failed.
Then there's no chance of any further fetchlinks in the $url $val.
So should not exit and should continue to circulate
Every time you fetchlinks to the URL is stored in the $urlarray and does not participate in subsequent lookups
So at the very end of the $url traversal is over. This takes all the first-level connections that may exist in the $url
Look at your needs, it seems that you should follow the access to the connection has been deep down
Suppose $netbot->results is a one-dimensional array of connections, name
for ($i =0; $i
if ($netbot->fetchlinks ($val)) {//If there is a link $url = array_merge ($url, $netbot->results);//Add the connection to the search queue }}
Did you get the wrong break and exit?
Did the landlord give up?
It should be recycled in the first condition of the IF