我有三个阵列。如何按键顺序对它们进行排序
Array
(
[network-id] => 4
[network-subdomain] => n3
[source-id] => 89
[about-page-id] => 5613
[contacts-page-id] => 2605
[logo-provider] => option-tree
[alias] => Template 3
[template-subdomain] => template3
[order] => 3
)
Array
(
[network-id] => 2
[network-subdomain] => n1
[source-id] => 87
[about-page-id] => 2
[contacts-page-id] => 2754
[logo-provider] => redux
[alias] => Template 1
[template-subdomain] => template1
[order] => 1
)
Array
(
[network-id] => 3
[network-subdomain] => n2
[source-id] => 88
[about-page-id] => 2
[contacts-page-id] => 26
[logo-provider] => option-tree
[alias] => Template 2
[template-subdomain] => template2
[order] => 2
)
答案 0 :(得分:1)
您可以使用usort
进行排序function compare_order($a, $b)
{
return strnatcmp($a['order'], $b['order']);
}
// sort alphabetically by order
usort($a, 'compare_order');
您可以看到demo