I just started learn php and I have some problems when I get somting in array in WordPress. for example
I get array like this [0,1,2,3,4]
after get the array I need to reverse it like this [4,3,2,1,0]
this my code of array
$gallery_images = array_values(get_children('pos_type=attachment&post_mime_type=image&post_parent=' . $gallery->ID));
You can add array_reverse() to reverse your array. This will do the trick for you.
$gallery_images = array_reverse(array_values(get_children('pos_type=attachment&post_mime_type=image&post_parent=' . $gallery->ID)));
Easiest way to reverse a standard idexed array in php is to use the array_reverse function.
But if you are just going to loop it out, you might as well use a backwards for-loop:
for($i=count($array);$i-->0;) {
echo $array[$i];
}
Which will loop the array in reverse direction.