我想對變量中保存的數據進行排序。我首先將它轉換爲一個數組,然後嘗試按升序對其進行排序,但似乎沒有工作。爲什麼我的php腳本不能排序數組?
這裏是我的代碼
$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>";
}
什麼解決辦法呢?
哪裏是要排序的代碼?只能看到它打印分割的結果.. –
$ 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)); asort($ cars,1); $ clength = count($ cars); ($ x = 0; $ x <$ clength; $ x ++) { echo $ cars [$ x]; echo「
」; } –