简体   繁体   中英

How to sort Json_encode on php?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM