1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
$tableau = array(
array('Station :' => 'CNITC15XFD',
'Espace libre :'=> 14699315200,
'Espace total :'=> 32210161664,
'pourcentage :' =>45.635645524961),
array('Station :'=> 'CNITC15ASE',
'Espace libre :'=> 92581924864,
'Espace total :' =>113632239616,
'pourcentage :'=> 81.475050722281),
array('Station :'=> 'CNITC15TFG',
'Espace libre :'=> 1000000000,
'Espace total :' =>32210161664,
'pourcentage :'=> 3.1046103103471),
array('Station :' => 'CNITC15CAD',
'Espace libre :' => 20000000000,
'Espace total :' => 113632239616,
'pourcentage :' => 17.600638751455),
array('Station :' => 'CNITC15ASR',
'Espace libre :' => 14699315200,
'Espace total :' => 32210161664,
'pourcentage :' => 45.635645524961)
);
$tableau_trie = array();
foreach($tableau as $cle=>$valeur)
if(!isset($tableau_trie[(string)$valeur['pourcentage :']]))
$tableau_trie[(string)$valeur['pourcentage :']] = $valeur;
else{
$cle_tab = $valeur['pourcentage :'];
while(true){
$new_cle_tab = $valeur['pourcentage :'].mt_rand(1, 100);
if($new_cle_tab != $cle_tab)
break;
}
$tableau_trie[(string)$new_cle_tab] = $valeur;
}
ksort($tableau_trie, SORT_NUMERIC);
$tableau_trie = array_values($tableau_trie);
echo '<pre>';
print_r($tableau_trie);
echo '<pre>';
/*
Affiche:
Array
(
[0] => Array
(
[Station :] => CNITC15TFG
[Espace libre :] => 1000000000
[Espace total :] => 32210161664
[pourcentage :] => 3.1046103103471
)
[1] => Array
(
[Station :] => CNITC15CAD
[Espace libre :] => 20000000000
[Espace total :] => 113632239616
[pourcentage :] => 17.600638751455
)
[2] => Array
(
[Station :] => CNITC15XFD
[Espace libre :] => 14699315200
[Espace total :] => 32210161664
[pourcentage :] => 45.635645524961
)
[3] => Array
(
[Station :] => CNITC15ASR
[Espace libre :] => 14699315200
[Espace total :] => 32210161664
[pourcentage :] => 45.635645524961
)
[4] => Array
(
[Station :] => CNITC15ASE
[Espace libre :] => 92581924864
[Espace total :] => 113632239616
[pourcentage :] => 81.475050722281
)
)
*/ |
Partager