Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从preg_match_all获得钥匙?_Php_Preg Match All - Fatal编程技术网

Php 如何从preg_match_all获得钥匙?

Php 如何从preg_match_all获得钥匙?,php,preg-match-all,Php,Preg Match All,代码正在运行: $url = 'http://www.google.com/search?hl=en&tbo=d&site=&source=hp&q=upoznavanje'; $html = file_get_html($url); preg_match_all('/(?<="><cite>).*?(?=<\/cite><div\ class=)/', $html, $output); foreac

代码正在运行:

$url  = 'http://www.google.com/search?hl=en&tbo=d&site=&source=hp&q=upoznavanje';
$html = file_get_html($url);
preg_match_all('/(?<="><cite>).*?(?=<\/cite><div\ class=)/', $html, $output);
    
foreach ($output[0] as $link) { 
  $link ."<br>"  ;
}

我发现了如何在无循环的情况下从数组中提取单个数据:

print_r($output[0][0]);

这可能会重复5分钟左右,因为谷歌真的很擅长阻止人们刮取他们的搜索结果。刮器一直工作得很好,当我把它放在foreach中时,我不明白为什么不使用$output[0]$link;这是一条毫无意义的线,因为它实际上什么都不做。另外,你能发布var_dump$output的结果吗;是的,缺少echo,我试图删除所有非点代码,但我想告诉大家foreach是有效的,有varu dump:array1{[0]=>array10{[0]=>string21[1]=>string47[2]=>string39[3]=>string30[4]=>string22 www.prvi-sastanak.net/[5]=>string122 najbolji-sajtovi-za-upoznavanje-i-dejt-foto
print_r($output[0][0]);