Re-order array in PHP

In this post I will share you PHP tip about Re-order array in PHP. It ‘s quite simple but it can take time if you don’t know this simple way. Now let ‘s me show you the situation.

inside-php-arrays-300x295

We have this array

We do the unset to remove the empty value element in array

It will become like this

But we need it like this

And ok, here is the magic to make it become like what we need

 

One comment

  1. It ‘s really nice way to re-order the PHP array, it can be done in refactor code

Leave a Reply

Your email address will not be published. Required fields are marked *

*