My question is simple, but for me, it is creating so many confusions in my mind. I want to know that can we input an array to curl function ?
please note that 'I AM NOT POSTING DATA' (FOR POSTING DATA , I KNOW, ARRAY IS USED)
To make my question more clear, let me tell you the code ..
function mycurl($url){
$ch = curl_init(); // create a new cURL resource
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$data = curl_exec($ch); // grab URL and pass it to the browser
//echo $data; //ncomment for debugging
curl_close($ch);
return $data;
}
and array i am going to use is
myArray
0 => string 'http://www.abc.com/a
1 => string 'http://www.abc.com/b
2 => string 'http://www.abc.com/c
3 => string 'http://www.abc.com/d
to use the array, I am using foreach loop the code is given below
foreach ($myArray as $temp){
$heading= mycurl($temp);
echo $heading;
}
the purpose of the code is
go to each url of array using curl function extract required data from the url process the next element of array and extract data and so on
Can anybody guide me that How can i use array elements in curl function?
How can i get my objective? If foreach loop is not the correct methodology here, then what should I do?