我正在尝试按特定顺序对数组进行排序:
我的代码(当前数组):
Array
(
[25] => Array
(
[1st place] =>
)
[15] => Array
(
[2nd place] =>
)
[10] => Array
(
[3rd place] =>
)
[5] => Array
(
[4th place] =>
[5th place] =>
[6th place] =>
[7th place] =>
[8th place] =>
[9th place] =>
[10th place] =>
)
[1] => Array
(
[11th place] =>
[12th place] =>
[13th place] =>
[14th place] =>
[15th place] =>
[16th place] =>
[17th place] =>
[18th place] =>
[19th place] =>
[20th place] =>
[21st place] =>
[22nd place] =>
[23rd place] =>
[24th place] =>
[25th place] =>
)
)
需要数组:
Array
(
[0] => Array
(
[1st place] => 25
)
[1] => Array
(
[2nd place] => 15
)
[5] => Array
(
[3rd place] => 10
)
[3] => Array
(
[4th place] => 5
[5th place] => 5
[6th place] => 5
[7th place] => 5
[8th place] => 5
[9th place] => 5
[10th place] => 5
)
[4] => Array
(
[11th place] => 1
[12th place] => 1
[13th place] => 1
[14th place] => 1
[15th place] => 1
[16th place] => 1
[17th place] => 1
[18th place] => 1
[19th place] => 1
[20th place] => 1
[21st place] => 1
[22nd place] => 1
[23rd place] => 1
[24th place] => 1
[25th place] => 1
)
)
这个想法就像使用数组位置(?)作为键的值并按以下顺序设置数组:
我正在尝试使用该代码(php)
foreach ($newOptions as $ord) {
$place = $ord[$idx];
$value = $ord[$idx][0];
$newOrderarr[$idx][$value][$place] = $name2;
$idx++;
}
但也不是很好 $newoptions 是我使用的数组...