Home > Backend Development > PHP Tutorial > 数组转json 结构的转换

数组转json 结构的转换

WBOY
Release: 2016-06-23 09:15:08
Original
1006 people have browsed it

我的数组是Array
(
    [1] => Array
        (
            [aid] => 1
            [pid] => 0
            [brand] => young
            [id] => 2
            [uname] => young1
            [groups] => 3
            [sub] => Array
                (
                    [2] => Array
                        (
                            [aid] => 1
                            [pid] => 2
                            [brand] => young
                            [id] => 3
                            [uname] => young2
                            [groups] => 4
                        )

                    [3] => Array
                        (
                            [aid] => 1
                            [pid] => 2
                            [brand] => young
                            [id] => 4
                            [uname] => young3
                            [groups] => 4
                        )

                )

        )这样的 
我用json转是这样的

如何把画圈的去掉,因为这样app解析不了


回复讨论(解决方案)

$new_data = array();foreach ($data as $itm) {	$itm['sub'] = array_values($itm['sub']);	$new_data[] = $itm;}
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template