php list order code example
Example 1: sort array php
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
asort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
//Would output:
c = apple
b = banana
d = lemon
a = orange
Example 2: php rearrange array
function rearrange_array($array, $key) {
while ($key > 0) {
$temp = array_shift($array);
$array[] = $temp;
$key--;
}
return $array;
}