PHP sort() function sorts an array. Elements will be arranged from lowest to highest when this function has completed. It will returns TRUE on success or FALSE on failure.
Syntax:
sort ( array &$array [, int $sort_flags = SORT_REGULAR ] ) : bool
Example #1 sort() example
$val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?>
Output
fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange
Example #2 sort() example using case-insensitive natural ordering
$val) { echo "fruits[" . $key . "] = " . $val . "\n"; } ?>
The above example will output:
fruits[0] = Orange1 fruits[1] = orange2 fruits[2] = Orange3 fruits[3] = orange20
The post PHP | sort() Function appeared first on FreeWebMentor.
This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here