Answers for "php sort numeric array ascending"

PHP
3

sort array php

<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
asort($fruits);
foreach ($fruits as $key => $val) {
    echo "$key = $valn";
}
?>
//Would output:
c = apple
b = banana
d = lemon
a = orange
Posted by: Guest on April-22-2020
1

php sort array by value

$price = array();
foreach ($inventory as $key => $row)
{
    $price[$key] = $row['price'];
}
array_multisort($price, SORT_DESC, $inventory);
Posted by: Guest on June-19-2021

Code answers related to "php sort numeric array ascending"

Browse Popular Code Answers by Language