Answers for "php array sort by value asc"

PHP
2

php array sort by key value

To PHP sort array by key, you should use: 
	ksort() (for ascending order) or krsort() (for descending order). 
      
To PHP sort array by value, you will need functions:
	asort() and arsort() (for ascending and descending orders).
Posted by: Guest on October-23-2020
0

array sort php

<?php

$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
    echo $val;
}
/*
OUTPUT:
apple
banana
lemon
orange
*/
?>
Posted by: Guest on May-14-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
0

php rearrange array

function rearrange_array($array, $key) {
    while ($key > 0) {
        $temp = array_shift($array);
        $array[] = $temp;
        $key--;
    }
    return $array;
}
Posted by: Guest on November-19-2020

Code answers related to "php array sort by value asc"

Browse Popular Code Answers by Language