Brendan Mullan
Brendan Mullan

Reputation: 117

Loop array for scrape

I have an array with some values

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

And i have some scrape code from simple html dom

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

I want to be able to give the url the values from the array one at a time so it will scrape the url with search=bob then go to search=jim and so on

I tried putting the file_get_html with the itterations and so on in a loop then use

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

But this wont work, anyway to do this?

Upvotes: 1

Views: 124

Answers (1)

Martin
Martin

Reputation: 6687

You need to use " instead of '. The double quotes allow variables to be used within a string. Alternatively use concatenation:

$html = file_get_html('http://somesite.com?search=' . $arrays);

Upvotes: 6

Related Questions