Search code examples
phpjavascriptjsonobjectstringify

Decode and get data of JS object in PHP


I have a variable named

var type = [];

where i do

type.push({'type' : 1});

and finally i get the following object:

[{"type":"1"},{"type":"2"},{"type":"3"},{"type":"4"}]

by doing JSON.stringify();

but how can i get the type inside PHP?


Solution

  • You can use json_decode

    $object = json_decode($json);