Changes

PHP Arrays

82 bytes added, 19:37, 1 June 2007
Sorting an Array
The above example uses the ''array_splice()'' function to replace the Three, Four and Five with the Six, Seven and Eight from the $myReplacements array.
== Sorting an a PHP Array ==
An array can be sorted using the ''sort'' function. A number of different sorts are possible using the ''sort'' function. The function takes two arguments. The first argument is the name of the array. The second indicates the sort algorithm to use. the avialable algorithms are SORT_NUMERIC, SORT_STRING and SORT_REGULAR. If no sort type is specified, SORT_REGULAR is used.
sort($colorArray, SORT_STRING);
</pre>
 
It is also possible to perform a Natural Sort using the ''natsort'' function.
== Sorting Associative Arrays ==