In my local environment I'm using the PHP7 and I developed a Restful API to an AngularJS application. I need do a get request to the Api and pass an array as parameter, so I did it:
$http.get("/Api/MyUrl.php", {
params: {
"Names[]": ["Foo", "Bar"]
}
})
.then(function(response){ //fires in success
console.log(response.data);
}, function(response){ //fires in error
console.log(response.statusText);
});
In MyUrl.php file I printed the parameters in the screen like this:
<?php
print_r($_GET);
?>
When it was executed, exactly what I imagined was printed on the browser console:
Array
(
[Names] => Array
(
[0] => Foo
[1] => Bar
)
)
Until here there's no problem. But, when I uploaded the application in the server, that supports only the 5.6 PHP version (I don't know if it's correlated, but I think so), the parameter with the array is gotten by the PHP in another way, and what is printed on console is that:
Array
(
[Names%5B%5D] => Bar
)
It "undestands" the [] signals as its HTML codes (%5B and %5D), get only the last element of the array and interprets as a commom variable.
What I need to do to read the parameters in the server in the same way that I do in the local environment?