Reputation: 311
How can I convert php's POST variable to json format?
Upvotes: 16
Views: 35967
Reputation: 23972
If this is entirely in php, and you simply want to convert the data in $_POST
to JSON, you can do so like this:
$json = json_encode($_POST);
Using php's built-in function json_encode
(doc)
If this is not what you want to do, please be more specific with your question.
Upvotes: 49