I have a simple array. The array length always has a square root of an integer. So 16, 25, 36 etc.
$array = array('1', '2', '3', '4' ... '25');
What I do, is arrange the array with HTML so that it looks like a block with even sides.
What I want to do, is sort the elements, so that when I pass the JSON encoded array to jQuery, it will iterate the array, fade in the current block, and so I'd get a sort of wave animation. So I'd like to sort the array kind of like this
So my sorted array would look like
$sorted = array('1', '6', '2', '3', '7', '11', '16, '12' .. '25');
Is there way to do so?.. Thanks
With a single loop and taking advantage of the simetry and with no sorts:
One more PHP solution, using just
for
andif
, traverses array only onceHere it is in action