Skip to content
Advertisement

How to reverse this json

I have a problem about array reversing. I tried array_reverse(…,true) But it is not working. May be the place that i applied is wrong. So i already attached my php code and json result below. Plz help me to reverse this json.

This is resultant json. What i want is, i want to reverse this. After reversion

Thank you

Advertisement

Answer

If what you are looking for is to just have ID’s go descending instead of ascending, you dont need to revise the whole array. You could just query the db to deliver data in that order and just run through it as you already do.

Change this:

To this:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement