I'm trying to receive an array via a cURL POST request, and I'm having an extrange issue.
Long story short: This is an api controller we're in, and when I json_encode a response...
echo json_encode($_POST['keys']); return;
The result (at the calling end of the api communication):
array(361) {
[0]=>
string(26) "some+urlencoded+string"
[1]=>
string(14) "and+some+other"
...
}
and so on. So the api receives my argument array no problem.
Then in the api I try a foreach loop to urldecode each string, to have those values in some other array:
$myArray = array();
foreach ($_POST['keys'] as $key => $value)
{
$myArray[$key] = urldecode($value);
// Or $myArray[] = urldecode($value); -- same result
}
echo json_encode($myArray); return;
And this is the result:
NULL
What am I doing wrong?
Thanks in advance :)
==================================================================================
EDIT: The problem seems to be that, in the api controller (that lives in a yii application) urledecode does not work. Neither does utf8_decode, nor base64_decode. At least they do not work inside a foreach loop, anyway. Why don't they work? Beats me. I'm still stuck.
==================================================================================
EDIT 2: I've made some progress in the isolation of the problem, asked another Q here at SO. Sorry for this, might as well be closed.
PHP (CI) cURL passed multidimensional array does not behave as one (Can't loop it)