15 June 2012

I have an application that uses HTTP POST to submit a JSON encoded array. Basically there are no variables that are being submitted, just JSON. This causes $_REQUEST and $_POST arrays to get messed up where “random” parts of the JSON will end up as the key and rest as the value. Instead what you need to do is get contents of the request as input then decode it   e.g.

    $input = file_get_contents('php://input');
    $my_array = json_decode( $input, TRUE);