I want the scores to be ordered, and then randomized so the items aren't in the same place every time. Does that make sense?
Array
(
[0] => Array
(
[id_entreprise] => 171
[title_entreprise] => chateaua
[name_entreprise] =>
[commune_entreprise] => Bordeaux
[score] => 7
)
[1] => Array
(
[id_entreprise] => 173
[title_entreprise] => chateaub
[name_entreprise] => Château B
[commune_entreprise] => Saint-Emilion
[score] => 10
)
[2] => Array
(
[id_entreprise] => 178
[title_entreprise] => chateauf
[name_entreprise] =>
[commune_entreprise] =>
[score] => 12
)
[3] => Array
(
[id_entreprise] => 176
[title_entreprise] => chateaud
[name_entreprise] =>
[commune_entreprise] =>
[score] => 7
)
)
Code :
$scoreCol = array_column($chateaux, 'score');
array_multisort($scoreCol, SORT_DESC, $chateaux);
For some reason, whenever they're sorted by scores, they're also sorted alphabetically by id or title (i don't know)! I either need to know how to randomize the sorted array, while keeping the score in numerical order.
Aucun commentaire:
Enregistrer un commentaire