On a local version of a project I've been building, I've been sending a JSON string as a HTTP query parameter, and using the json_decode()
function to decode the string back into a PHP array.
Locally, this was working fine (XAMPP) however when I upload these files to my clients server, they no longer work. I have diagnosed this as an issue where the parameter for which the JSON string is passed as e.g. o=[{"b_id":"1","p_ref_id":"SHAY899","b_name":"John Smith"}]
isn't picked up in the global $_GET
array.
I thought perhaps the version of PHP required to encode/decode JSON wasn't available, however I use the json_encode()
in other parts of this project, so that can't be the issue. I'm wondering perhaps if it's a max character length issue, and if so how would I solve it (or where would I start at least)?
If not, any other help would be very greatly appreciated!!
Use:
$string = urlencode(json_encode($array));
and using the
$array = urldecode(json_decode($string));
to decode the string back into a PHP array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With