score並べ替えようとしている値を含むキーで並べ替えようとしている配列があります。望ましい結果は、以下の配列の順序を変更して、次の順序でインデックスを表示することです: [0]、[2]、[1]。
データベースから取得した結果をループしています。という名前のキーを作成し、それを使用するとキーが削除されるため、配列を別の配列にscoreプッシュしています。$row2mysql_data_seekscore
また、下部に不要なキーscoreを作成しています。
これをクリーンアップして、結果が必要に応じて上位から下位に並べられるようにするにはどうすればよいですか?
$my_array = array();
while ($row2 = mysql_fetch_assoc($result2))
{
//score determined here
//$row2['score'] = ...more math, variable is numeric, not a string
array_push($array_page,$row2);
}
現在の望ましくない結果...
Array
(
[0] => Array
(
[score] => 7
)
[1] => Array
(
[score] => 2
)
[2] => Array
(
[score] => 4
)
[score] =>
)
望む結果…
Array
(
[0] => Array
(
[score] => 7
)
[2] => Array
(
[score] => 4
)
[1] => Array
(
[score] => 2
)
)