私は以下の配列を動的に作成しました。連想配列を特定の要件で並べ替える
Array
(
[1x2] => Array
(
[AWAY] => Array
(
[PL] => 1.6
[Yield] => 19.4
[YieldLS] => 19.4
[Picks] => 8
[Price] => 14.97
[Stake] => 8
[AvgStake] => 1
[AvgOdd] => 1.87
)
[HOME] => Array
(
[PL] => 6.9
[Yield] => 34.7
[YieldLS] => 34.7
[Picks] => 20
[Price] => 38.25
[Stake] => 20
[AvgStake] => 1
[AvgOdd] => 1.91
)
[DRAW] => Array
(
[PL] => 2.4
[Yield] => 240
[YieldLS] => 240
[Picks] => 1
[Price] => 3.4
[Stake] => 1
[AvgStake] => 1
[AvgOdd] => 3.4
)
[TOTAL] => Array
(
[PL] => 10.9
[Yield] => 294.1
[YieldLS] => 294.1
[Picks] => 29
[Price] => 56.62
[Stake] => 29
[AvgStake] => 3
[AvgOdd] => 7.18
)
)
[Asian Handicap] => Array
(
[HOME] => Array
(
[PL] => 41.9
[Yield] => 9.3
[YieldLS] => 9.3
[Picks] => 448
[Price] => 885.79
[Stake] => 448
[AvgStake] => 1
[AvgOdd] => 1.98
)
[AWAY] => Array
(
[PL] => 31.3
[Yield] => 7.1
[YieldLS] => 7.1
[Picks] => 439
[Price] => 877.33
[Stake] => 439
[AvgStake] => 1
[AvgOdd] => 2
)
[TOTAL] => Array
(
[PL] => 73.2
[Yield] => 16.4
[YieldLS] => 16.4
[Picks] => 887
[Price] => 1763.12
[Stake] => 887
[AvgStake] => 2
[AvgOdd] => 3.98
)
)
[Over/Under] => Array
(
[OVER] => Array
(
[PL] => 14.7
[Yield] => 10.1
[YieldLS] => 10.1
[Picks] => 145
[Price] => 281.45
[Stake] => 145
[AvgStake] => 1
[AvgOdd] => 1.94
)
[UNDER] => Array
(
[PL] => 14.1
[Yield] => 19.5
[YieldLS] => 19.5
[Picks] => 72
[Price] => 140.94
[Stake] => 72
[AvgStake] => 1
[AvgOdd] => 1.96
)
[TOTAL] => Array
(
[PL] => 28.8
[Yield] => 29.6
[YieldLS] => 29.6
[Picks] => 217
[Price] => 422.39
[Stake] => 217
[AvgStake] => 2
[AvgOdd] => 3.9
)
)
)
私がしたいのは、特定の要件に従ってソートすることです。例えば、私が最初のレベルの
Array
(
[1x2] => Array
(
[HOME] => Array
(
[PL] => 6.9
[Yield] => 34.7
[YieldLS] => 34.7
[Picks] => 20
[Price] => 38.25
[Stake] => 20
[AvgStake] => 1
[AvgOdd] => 1.91
)
[DRAW] => Array
(
[PL] => 2.4
[Yield] => 240
[YieldLS] => 240
[Picks] => 1
[Price] => 3.4
[Stake] => 1
[AvgStake] => 1
[AvgOdd] => 3.4
)
[AWAY] => Array
(
[PL] => 1.6
[Yield] => 19.4
[YieldLS] => 19.4
[Picks] => 8
[Price] => 14.97
[Stake] => 8
[AvgStake] => 1
[AvgOdd] => 1.87
)
[TOTAL] => Array
(
[PL] => 10.9
[Yield] => 294.1
[YieldLS] => 294.1
[Picks] => 29
[Price] => 56.62
[Stake] => 29
[AvgStake] => 3
[AvgOdd] => 7.18
)
)
[Asian Handicap] => Array
(
[HOME] => Array
(
[PL] => 41.9
[Yield] => 9.3
[YieldLS] => 9.3
[Picks] => 448
[Price] => 885.79
[Stake] => 448
[AvgStake] => 1
[AvgOdd] => 1.98
)
[AWAY] => Array
(
[PL] => 31.3
[Yield] => 7.1
[YieldLS] => 7.1
[Picks] => 439
[Price] => 877.33
[Stake] => 439
[AvgStake] => 1
[AvgOdd] => 2
)
[TOTAL] => Array
(
[PL] => 73.2
[Yield] => 16.4
[YieldLS] => 16.4
[Picks] => 887
[Price] => 1763.12
[Stake] => 887
[AvgStake] => 2
[AvgOdd] => 3.98
)
)
[Over/Under] => Array
(
[OVER] => Array
(
[PL] => 14.7
[Yield] => 10.1
[YieldLS] => 10.1
[Picks] => 145
[Price] => 281.45
[Stake] => 145
[AvgStake] => 1
[AvgOdd] => 1.94
)
[UNDER] => Array
(
[PL] => 14.1
[Yield] => 19.5
[YieldLS] => 19.5
[Picks] => 72
[Price] => 140.94
[Stake] => 72
[AvgStake] => 1
[AvgOdd] => 1.96
)
[TOTAL] => Array
(
[PL] => 28.8
[Yield] => 29.6
[YieldLS] => 29.6
[Picks] => 217
[Price] => 422.39
[Stake] => 217
[AvgStake] => 2
[AvgOdd] => 3.9
)
)
)
1x2
として出力を必要とする最初の項目、Asian Handicap
及び最後Over/Under
であるべきです。同様に1x2
およびHandicap
の第2レベルはHome, Draw, Away and Total
である必要があります。 の第2レベルはOver then Under and then Total
です。不足している項目/要素については、空のレコード/配列を追加する必要があります。 elements
とkeys
の数は常に固定されます。
見つからない場合は、私は、ソートが、配列が欠落して一度に複雑で作られたソートのロジックを置くための別の配列を使用してみましたが、この
Array
(
[1x2] => Array
(
[HOME] => Array
(
[PL] => ''
[Yield] => ''
[YieldLS] => ''
[Picks] => ''
[Price] => ''
[Stake] => ''
[AvgStake] => ''
[AvgOdd] => ''
)
[DRAW] => Array
(
[PL] => 2.4
[Yield] => 240
[YieldLS] => 240
[Picks] => 1
[Price] => 3.4
[Stake] => 1
[AvgStake] => 1
[AvgOdd] => 3.4
)
[AWAY] => Array
(
[PL] => 1.6
[Yield] => 19.4
[YieldLS] => 19.4
[Picks] => 8
[Price] => 14.97
[Stake] => 8
[AvgStake] => 1
[AvgOdd] => 1.87
)
[TOTAL] => Array
(
[PL] => 10.9
[Yield] => 294.1
[YieldLS] => 294.1
[Picks] => 29
[Price] => 56.62
[Stake] => 29
[AvgStake] => 3
[AvgOdd] => 7.18
)
)
[Asian Handicap] => Array
(
[HOME] => Array
(
[PL] => 41.9
[Yield] => 9.3
[YieldLS] => 9.3
[Picks] => 448
[Price] => 885.79
[Stake] => 448
[AvgStake] => 1
[AvgOdd] => 1.98
)
[AWAY] => Array
(
[PL] => ''
[Yield] => ''
[YieldLS] => ''
[Picks] => ''
[Price] => ''
[Stake] => ''
[AvgStake] => ''
[AvgOdd] => ''
)
[TOTAL] => Array
(
[PL] => 73.2
[Yield] => 16.4
[YieldLS] => 16.4
[Picks] => 887
[Price] => 1763.12
[Stake] => 887
[AvgStake] => 2
[AvgOdd] => 3.98
)
)
[Over/Under] => Array
(
[OVER] => Array
(
[PL] => 14.7
[Yield] => 10.1
[YieldLS] => 10.1
[Picks] => 145
[Price] => 281.45
[Stake] => 145
[AvgStake] => 1
[AvgOdd] => 1.94
)
[UNDER] => Array
(
[PL] => 14.1
[Yield] => 19.5
[YieldLS] => 19.5
[Picks] => 72
[Price] => 140.94
[Stake] => 72
[AvgStake] => 1
[AvgOdd] => 1.96
)
[TOTAL] => Array
(
[PL] => 28.8
[Yield] => 29.6
[YieldLS] => 29.6
[Picks] => 217
[Price] => 422.39
[Stake] => 217
[AvgStake] => 2
[AvgOdd] => 3.9
)
)
)
のようにすることができます。どんな助力も高く評価されます。
良いアイデアのようです。私はこれを試してみる。 –
いくつかのサンプルコードを追加しましたが、テストされていませんでした。確認できますか? – Fiber
私はそれらを試してみましょう。 –