我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何在php上对Json_encode进行排序?

I have a .php file that gets data from SQL and then produces them as json array using json_encode. What I would like to know is, is it possible to sort them? or anything along those lines? Thanks

You need to sort, order, group or whatever you like them in either the sql query or through array manipulation before using json_encode.

json_encode (as it is clear from its name) is only used for encoding the data, not sorting etc. Whatever you give it, it will just encode/serialize to json.

近期文章

  • 在Yii中获取验证码无效
  • 如果in_array在多维数组上
  • curl在YouTube中没有匹配 - 返回null
  • 使用PHP 4从数据库输出XML
  • 在Laravel组织儿童收集
  • 在Laravel Eloquent中获得独特的孩子
  • Php Web服务器通用Cookie注入
  • 将变量添加到使用jquery发布的数据
  • 数组codeigniter中的字符串转换错误
  • PHP菜单:用于父项的循环
  • 使用php更新数据库中正确行的问题
  • 拆分多维数组用于数组交集
  • 在Windows 7上安装EasyPHP Devserver14.1 VC11
  • 为什么the_permalink只回显基类?
  • 如果遇到条件,从多维数组中获取随机数组值
  • 在大型MySQL数据库中用random int替换字符串的最快方法?
  • 在Laravel 4.2中保护视图的最有效方法是什么?
  • 有没有办法配置JMS Serializer来忽略注释?
  • 转换为日期的纪元时间在UTC和PHP上都不同
  • 使用PHP错误的摘要值

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华