Get usable array from a curl response, which is formatted as a php array
- by Mint
$ch = curl_init("url");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "test");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$outputArray = curl_exec($ch);
Then $outputArray will contain:
Array
(
[0] => Array
(
[r1] => test response
[r2] => 4
[r3] => 32
)
)
So I would think PHP can see that it's an array and treat it as such, but when I do something like
echo $outputCode[0][r_title]."\n";
it gives an error:
PHP Fatal error: Cannot use string offset as an array in /www/test.php on line 75
(line 75 being the echo one just above)
What am I doing wrong?