Php 按值对数组进行递归排序
如何按值对关联数组进行递归排序。 我有一个名为“order”的键和一个数值,我想用它对数组进行排序。 这里有一个例子Php 按值对数组进行递归排序,php,sorting,recursion,Php,Sorting,Recursion,如何按值对关联数组进行递归排序。 我有一个名为“order”的键和一个数值,我想用它对数组进行排序。 这里有一个例子 array( "something_one" => array( "one" => "content sample", "two" => "content sample", "order" => 4 "next" => NULL ), "something_two" => array( "o
array(
"something_one" => array(
"one" => "content sample",
"two" => "content sample",
"order" => 4
"next" => NULL
),
"something_two" => array(
"one" => "content sample",
"two" => "content sample",
"order" => 1
"next" => array(
"something_four" => array(
"one" => "content sample",
"two" => "content sample",
"order" => 2
"next" => NULL
),
)
),
"something_three" => array(
"one" => "content sample",
"two" => "content sample",
"order" => 3
"next" => NULL
)
);
我想我找到了答案
array_value_multisort($array, 'order', 'next');
你能给出一个你期望的输出的例子吗?我不想按“顺序”值排序,我明白了。但是你有一个嵌套数组(在你的例子中是key
something\u four
),你说的是递归排序,所以…你想把结果展平吗?请给出您的示例的预期输出。到目前为止您尝试了什么?请向我们展示您在解决问题方面的最佳尝试。结果我不希望使用相同的数组,但需要排序。我认为一定有办法重建这个数组并构建排序/有序数组
array_value_multisort($array, 'order', 'next');