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

时间:2016-11-25 06:43:59

标签: php arrays json multidimensional-array

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
                    )

            )

    )

)

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

1 个答案:

答案 0 :(得分:0)

这是无效的json数组, 您可以使用following url

验证您的json数组或json对象

这是使用php

读取json对象的简单代码
$data = '{
    "name": "Saman",
    "age": "19",
         "records":[{
                "subject1":"Maths",
                "marks":"67"

            }]
        }';

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