将JSON stringify发送给PHP如何阅读它

In javascript i am using JSON.stringify it generate the below string

{"grid":[{"section":[{"id":"wid-id-1-1"},{"id":"wid-id-1-4"}]},{"section":[{"id":"wid-id-1-5"}]},{"section":[{"id":"wid-id-1-2"},{"id":"wid-id-1-3"}]}]}

i am calling php using ajax, i can get the string in PHP as it is, but after that how i should process it.

Below is my full code

 var mainArr = [];
        $('.sortable-grid')
                .each(function() {
                    var subArr = [];
                    $(this)
                            .children('.mygrid')
                            .each(function() {
                                var subObj = {};
                                subObj['id'] = $(this)
                                        .attr('id');
                                subArr.push(subObj);
                            });
                    var out = {
                        'section': subArr
                    };
                    mainArr.push(out);
                });

        var storePositionObj = JSON.stringify({
            'grid': mainArr
        });

$.ajax({
            url: __BASEURL + "php/update-details.php",
            data: {position: storePositionObj},

I recently started learning PHP, and don't know how to process this above string.

could any one please help.

thank you

regards, Mona

$json = json_decode($_POST['position']);

Try json_decode()

sample code below:

<?PHP
    $position = $_REQUEST['position'];
    print_r(json_decode($position));

Just use json_decode() method and then you can use it like an array.

You can use it like

$data = json_decode($your_stringify_json);
var_dump($data['grid']);