数组转换

WBOY
Release: 2016-06-23 13:49:24
Original
1101 people have browsed it

string(170) "{"grouds":[{"id":0,"name":"aaaa","count":8},{"id":1,"name":"bbb","count":0},{"id":2,"name":"cccc","count":0},{"id":100,"name":"dddd","count":1}]}"
这个怎么在网页中显示?或者怎么转成二维数组呢?


  • 0

  • aaaa

  • 8



  • 1

  • bbb

  • 0



  • 2

  • ccc

  • 0


  • .....................


    回复讨论(解决方案)

    $s ='{"grouds":[{"id":0,"name":"aaaa","count":8},{"id":1,"name":"bbb","count":0},{"id":2,"name":"cccc","count":0},{"id":100,"name":"dddd","count":1}]}';print_r(json_decode($s, true));
    Copy after login

    Array
    (
        [grouds] => Array
            (
                [0] => Array
                    (
                        [id] => 0
                        [name] => aaaa
                        [count] => 8
                    )

                [1] => Array
                    (
                        [id] => 1
                        [name] => bbb
                        [count] => 0
                    )

                [2] => Array
                    (
                        [id] => 2
                        [name] => cccc
                        [count] => 0
                    )

                [3] => Array
                    (
                        [id] => 100
                        [name] => dddd
                        [count] => 1
                    )

            )

    )

    json_decode

    你可以采用PHP 的jsondecode进行解析变成数组,也可以采用js进行遍历,看你自己意愿。

    就是一个函数调用的问题
    调用一个函数jsondecode即可解决。
    望采纳

    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