Answers for "how to use sort in particular array in php"

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

how to sort with array and after print by for loop in php

$cars = array("Volvo", "BMW", "Toyota");
sort($cars);

$clength = count($cars);
for($x = 0; $x < $clength; $x++) {
  echo $cars[$x];
  echo "<br>";
}
Posted by: Guest on December-21-2020

Code answers related to "how to use sort in particular array in php"

Browse Popular Code Answers by Language