there are two ways to sort elements of array. If you want a simple default ascending order sorting with non-object array elements, then you can go for “sort” function. You just pass the array as parameter and it will sort the array and returns true if succeed.
1
2
3
4
| $simple_array = array("dbc","bcd,"abc");if(sort($simple_array)){print_r($simpl_array);}
If you want to define your own logic for sort condition and/or you are using objects as element of array, go for “usort” function. Example:
|
No comments:
Post a Comment