Why is my php script not sorting an array? -


i trying sort data held in variable. first convert array try sort in ascending order seems not working.

here code

$str = '"10:a", "11:q", "12:v", "13:a", "14:g", "15:i", "16:e", "17:d", "18:n", "19:r", "1:a", "20:u", "2:x", "3:c", "4:d", "5:r", "6:u", "7:v", "8:i", "9:s"'; $cars = (explode(",",$str)); $cars = array($cars);  sort($cars, 1); $clength=count($cars); for($x=0;$x<$clength;$x++)   {   echo $cars[$x];   echo "<br>";   } 

any workaround this?

try rsort

$str = '"10:a", "11:q", "12:v"';     $cars = (explode(",",$str));      rsort($cars);     $clength=count($cars);     for($x=0;$x<$clength;$x++)       {       echo $cars[$x];       echo "<br>";       } 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -