1

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?

1
  • Side note: foreach($array as $arrayS) doesn't make sense, i would name it something like foreach($array as $name) :p Commented Mar 3, 2013 at 23:59

1 Answer 1

6

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);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.