I have the following code:
$mh = curl_multi_init();
$requests = array();
addSentimentHandle ( 'Hello', $requests );
addSentimentHandle ( 'Hello :)', $requests );
function addSentimentHandle($tweet, $requests) {
$url = makeURLForAPICall($tweet);
array_push($requests, curl_init ($url));
print_r($requests);
}
I would expect the $requests array to contain two elements, however this is the output:
Array ( [0] => Resource id #8 ) Array ( [0] => Resource id #9 )
Why are 2 arrays are being created instead of the second item being pushed into the same array?
addSentimentHandle(), have you tried passing the array by reference?function addSentimentHandle($tweet, &$requests) {}