Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中获取数组并将数组移动到对象_Php_Json - Fatal编程技术网

在php中获取数组并将数组移动到对象

在php中获取数组并将数组移动到对象,php,json,Php,Json,在json中,您可以简单地执行以下操作 { otherproperty: 'something', img : ['1.jpg'],['2.jpg']; } 请详细说明,不清楚你在说什么asking@user3346088,好的,您只需将$json_数组放入另一个语句中 { otherproperty: 'something', img : ['1.jpg'],['2.jpg']; } $json_array = array('otherpropert

在json中,您可以简单地执行以下操作

{
    otherproperty: 'something',
    img : ['1.jpg'],['2.jpg'];
}

请详细说明,不清楚你在说什么asking@user3346088,好的,您只需将$json_数组放入另一个语句中
{
    otherproperty: 'something',
    img : ['1.jpg'],['2.jpg'];
}
    $json_array = array('otherproperty' => "something", "img" => array())
    while ($array = $photo_items->fetch_array()) {

        array_push($json_array['img'], $array['img_src'])

    }
    echo json_encode($json_array);