dops57958 2011-05-27 02:42 采纳率: 0%
浏览 40
已采纳

传递GET时表示多维数组

Is there a way to represent/pass a multidimensional array like

array( array('foo' => 'bar') , array('language' => 'php'), ...);

into a GET string?

For simple arrays such as

array(1,2,3,4)

I can represent it like this

?ids=1,2,3,4

But I don't know how to represent multidimensional arrays

  • 写回答

4条回答 默认 最新

  • dongxiao_0528 2011-05-27 02:46
    关注

    There's several ways you could do it.

    One way is to serialize() it and then unserialize() it on the page that reads it.

    Another way is to json_encode() it and then json_decode() it on the page that reads it.

    Or, in keeping with the CSV-style it sounded like you prefer, you could just delimit the next layer of the array with a different delimiter, ex.

    array(
        0 => array(1, 2, 3),
        1 => array(4, 5, 6),
    )
    

    becomes

    ?array=1|2|3,4|5|6
    

    Finally, PHP will also parse arrays in the querystring like:

    ?array[0][0]=1&array[0][1]=2&array[0][1]=3&array[1][0]=4&array[1][1]=5&array[1][1]=6
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致