在php中的json_decode之后从json数组插入

时间:2022-10-26 14:21:50
Array
(
[0] => Array
    (
        [lead_id] => 1
        [employee_id] => 2
        [update_date] => 2016-11-25
        [lead_status] => Fresh Leads
        [reason] => Deal Won
        [notes] => Array
            (
                [0] => Array
                    (
                        [notes] => Notes 1
                    )

                [1] => Array
                    (
                        [notes] => Notes 2
                    )

                [2] => Array
                    (
                        [notes] => Notes 3
                    )

            )

    )

[1] => Array
    (
        [lead_id] => 1
        [employee_id] => 5
        [update_date] => 2016-11-25
        [lead_status] => Fresh Leads
        [reason] => Deal Won
        [notes] => Array
            (
                [0] => Array
                    (
                        [notes] => Notes 1
                    )

                [1] => Array
                    (
                        [notes] => Notes 2
                    )

                [2] => Array
                    (
                        [notes] => Notes 3
                    )

            )

    )

[2] => Array
    (
        [lead_id] => 3
        [employee_id] => 2
        [update_date] => 2016-11-25
        [lead_status] => Fresh Leads
        [reason] => Deal Won
        [notes] => Array
            (
                [0] => Array
                    (
                        [notes] => Notes 1
                    )

                [1] => Array
                    (
                        [notes] => Notes 2
                    )

                [2] => Array
                    (
                        [notes] => Notes 3
                    )

            )

    )

)

This is my json array.
How can I get the values of each fields from this array?
Please help

这是我的json数组。如何从此数组中获取每个字段的值?请帮忙

1 个解决方案

#1


0  

This is not valid json array, you can validate your json arrays or json objects using following url

这不是有效的json数组,您可以使用以下url验证您的json数组或json对象

this the simple code of read json object using php

这是使用php读取json对象的简单代码

$data = '{
    "name": "Saman",
    "age": "19",
         "records":[{
                "subject1":"Maths",
                "marks":"67"

            }]
        }';

$character = json_decode($data);
echo "Name :".$character->name;
echo "Age :".$character->age; 

#1


0  

This is not valid json array, you can validate your json arrays or json objects using following url

这不是有效的json数组,您可以使用以下url验证您的json数组或json对象

this the simple code of read json object using php

这是使用php读取json对象的简单代码

$data = '{
    "name": "Saman",
    "age": "19",
         "records":[{
                "subject1":"Maths",
                "marks":"67"

            }]
        }';

$character = json_decode($data);
echo "Name :".$character->name;
echo "Age :".$character->age;