php sort array remove keys 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 sort array remove keys
$arr = array(1, 2, 3);
unset($arr[0]);
$arr = array_values($arr);
print_r($arr);
//Array ( [0] => 2 [1] => 3 )