1

いくつかの値を持つ配列があります

$array = array("Bob","jim","frank","pat");

そして、私は単純なhtmldomからいくつかのスクレイプコードを持っています

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

配列から一度に1つずつURLに値を指定できるようにしたいので、search = bobでURLを取得してから、search=jimなどに移動します。

反復などを含むfile_get_htmlをループに入れてから、

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

しかし、これはうまくいきません、とにかくこれを行うには?

4

1 に答える 1

6

"の代わりに使用する必要があります'double quotes文字列内で変数を使用できるようにします。または、次を使用しますconcatenation

$html = file_get_html('http://somesite.com?search=' . $arrays);
于 2013-03-03T23:57:17.750 に答える