我有這樣陣列固定數字順序
array
0 =>
array
'title' => string 'Last Name' (length=9)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 1
1 =>
array
'title' => string 'Title 1' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
2 =>
array
'title' => string 'Title 10' (length=7)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
3 =>
array
'title' => string 'Title 11' (length=7)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
4 =>
array
'title' => string 'Title 12' (length=7)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
5 =>
array
'title' => string 'Title 2' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
6 =>
array
'title' => string 'Title 3' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
7 =>
array
'title' => string 'Title 4' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
8 =>
array
'title' => string 'Title 5' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
9 =>
array
'title' => string 'Title 6' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
10 =>
array
'title' => string 'Title 7' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
11 =>
array
'title' => string 'Title 8' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
12 =>
array
'title' => string 'Title 9' (length=6)
'price' => string '0.0000' (length=6)
'price_type' => string 'fixed' (length=5)
'is_required' => int 0
數組所以問題是,在數組中我有標題。當我做foreach循環標題顯示爲
LAST NAME:
Title 1:
Title 10:
Title 11:
Title 12:
Title 2:
Title 3:
Title 4:
Title 5:
Title 6:
Title 7:
Title 8:
Title 9:
正如你可以看到,標題10顯示出來之後緊接其不正確的數字順序。我怎樣才能解決這個問題。 謝謝
TRIED $ titles = array(); ($ product-> custom_options as $ key => $ row) { $ titles [$ key] = $ row ['title']; var_dump(array_multisort($ titles,SORT_DESC,$ product-> custom_options)); var_dump(array_multisort($ titles,SORT_DESC,$ product-> custom_options));
[排序在PHP多維數組]的可能重複(http://stackoverflow.com/questions/2059255/sorting-multidimensional-array-in-php) – bfavaretto
「修復順序」通常被稱爲「排序」 。 –