远程获取,然后直接echo 输出。前台用ajax请求你的PHP程序地址

解决方案 »

  1.   

    楼上正解,json_encode将php数组成json格式,json_decode将json转换成数组
      

  2.   

    json_decode,把你从API得到的数据转换成为数组,然后在程序当中获取你所需要的数组元素。
      

  3.   

    json_decode()
    json_encode()
    看下手册,上面会有很多demo的
      

  4.   

    $arr = array(1,2,3);
    print_r(json_encode($arr));
      

  5.   

    大家都没明白我的意思啊?
    问题是我对php不熟,它返回的这种格式在php数组怎么来写的?
      

  6.   


    问题是我对php不熟,它返回的这种格式在php数组怎么来写的?
      

  7.   

    header('Content-type: text/html;charset=utf-8');$s = '[{"nav_name":"\u7c73\u5382\u7b80\u4ecb","id":"2"},{"nav_name":"\u4f01\u4e1a\u6587\u5316","id":"3"},{"nav_name":"\u53d1\u5c55\u5386\u7a0b","id":"4"},{"nav_name":"\u8054\u7cfb\u6211\u4eec","id":"9"},{"nav_name":"\u516c\u53f8\u54c1\u724c","id":"25"},{"nav_name":"\u516c\u53f8\u8363\u8a89","id":"26"}]';
    var_export(json_decode($s, 1));
    array (
      0 => 
      array (
        'nav_name' => '米厂简介',
        'id' => '2',
      ),
      1 => 
      array (
        'nav_name' => '企业文化',
        'id' => '3',
      ),
      2 => 
      array (
        'nav_name' => '发展历程',
        'id' => '4',
      ),
      3 => 
      array (
        'nav_name' => '联系我们',
        'id' => '9',
      ),
      4 => 
      array (
        'nav_name' => '公司品牌',
        'id' => '25',
      ),
      5 => 
      array (
        'nav_name' => '公司荣誉',
        'id' => '26',
      ),
    )