在过去的3天里,我一直在尝试对数组进行排序,但没有成功。如何对这个数组进行排序?
我在php文件中首先尝试并在tpl文件中尝试,但是我不能排序我的数组。
你能帮我吗?
这是我的阵列结构(感谢smaty调试工具!):
Array (5)
attributes => Array (4)
23 => "1L"
24 => "3.5L"
21 => "50ml"
22 => "350ml"
name => "Contenance"
is_color_group => "0"
attributes_quantity => Array (4)
23 => 1
24 => 500
22 => 500
21 => 500
default => 21
我希望由上升“ID”进行排序它获得这种结果:
Array (5)
attributes => Array (4)
21 => "50ml"
22 => "350ml"
23 => "1L"
24 => "3.5L"
name => "Contenance"
is_color_group => "0"
attributes_quantity => Array (4)
21 => 500
22 => 500
23 => 1
24 => 500
default => 21
你有什么想法吗?
在用户功能无需阵列。 – zerkms 2010-08-06 14:30:53
你说得对,ksort就够了。 – 2010-08-06 14:36:06
谢谢,现在好多了! – bahamut100 2010-08-09 07:24:58