配列を特定の順序で並べ替えようとしています:
私のコード(現在の配列):
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は、私が使用している配列です...