I've been stuck trying to debug this .. im passing a multidimensional array to another script via cURL, and i wanted to do something with that array after passing it the curl execution .. however it seems that after the array passed through curl (a copy of it at least), the original array gets messed up!
$myarray[0]['name'] = "TJ";
$myarray[0]['age'] = "21";
$myarray[0]['sex'] = "yes please";
printr($myarray); //outputs the array properly
//upload the array data as-is to central
// Get cURL resource
$curl = curl_init();
// Set some options for cURL
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://localhost/projects/sync_dtr.php?',
CURLOPT_USERAGENT => 'TK local code: blq ',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $myarray
));
// Send the request & save response to $resp
$response = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
printr($myarray); //doesn't output the array properly, instead it outputs "Array ( [0] => Array ) "
is this a bug or an expected result/effect? i don't understand how cURL wrote/modified the original array. heck even if i make a copy of the $myarray , and use one copy in cURL , bot copies get messed up!!
but if i don't use multidimensional array, everything seems to be fine.