用于刮擦的循环阵列

Bre*_*lan 1 php

我有一个带有一些值的数组

$array = array("Bob","jim","frank","pat");
Run Code Online (Sandbox Code Playgroud)

我从简单的html dom中得到了一些scrape代码

$html = file_get_html('http://somesite.com?search=name');
//itteration and so on
Run Code Online (Sandbox Code Playgroud)

我希望能够一次一个地给出url数组中的值,所以它会用search = bob抓取url然后转到search = jim等等

我尝试将file_get_html与itterations一起放在循环中,然后使用

foreach($array as $arrays){
$html = file_get_html('http://somesite.com?search=$arrays');
//more code
}
Run Code Online (Sandbox Code Playgroud)

但这不会起作用,无论如何要做到这一点?

Mar*_*tin 6

你需要使用"而不是'.在double quotes允许的变量要在字符串中使用.或者使用concatenation:

$html = file_get_html('http://somesite.com?search=' . $arrays);
Run Code Online (Sandbox Code Playgroud)