在 PHP 中,我有这种数组(对不起,这个大例子,但它是一个特定的排序):
[0] => Array
(
[title] => 1
[desc] => 2
)
[1] => Array
(
[title] => 1
[desc] => 3
)
[2] => Array
(
[title] => 1
[desc] => 2
[content] => 10
)
[3] => Array
(
[title] => 1
[desc] => 2
[content] => 11
)
[4] => Array
(
[title] => 1
[desc] => 3
[content] => 9
)
[5] => Array
(
[title] => 1
[desc] => 2
[content] => 10
[tag] => 'foo'
)
[6] => Array
(
[title] => 1
[desc] => 2
[content] => 10
[tag] => 'bar'
)
我想要这个输出:
[0] => Array
(
[title] => 1
[desc] => 2
)
[1] => Array
(
[title] => 1
[desc] => 2
[content] => 10
)
[2] => Array
(
[title] => 1
[desc] => 2
[content] => 10
[tag] => 'bar'
)
[3] => Array
(
[title] => 1
[desc] => 2
[content] => 10
[tag] => 'foo'
)
[4] => Array
(
[title] => 1
[desc] => 2
[content] => 11
)
[5] => Array
(
[title] => 1
[desc] => 3
)
[6] => Array
(
[title] => 1
[desc] => 3
[content] => 9
)
不幸的是,array_multisort()
不能对具有非常量键的数组进行排序:它只是忽略了所有数组......知道吗?