par
mephiston » 20 sept. 2010, 15:51
Bonjour,
pour faire simple j'ai un fichier CSV que j'ouvre que je met dans un array et je souhaite trier cet array sur une colonne, je trouve plein de truc sur internet mais je suis incapable de l'utiliser.
voila mon code :
$uniqId = $_GET['uniqId'];
$type=$_GET['type'];
$fichier = 'exportCSV/Result'.$type.'_'.$uniqId.'.csv';
$handle = fopen($fichier, 'rb');
$cpt = 0;
while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
if ($cpt!=0)
{
if ($type=='Domaine1')
{
$tab[]=array('legend'=> $data[0], 'ydata' => str_replace('%', '', $data[2]), '$ydata2' => $data[3]);
}
else
{
$tab[]=array('legend'=> $data[0], 'ydata' => $data[4], '$ydata2' => '0');
}
}
$cpt++;
}
array_multisort($tab['ydata'], SORT_NUMERIC, SORT_DESC);
fclose($handle);
Si vous pouvez m'aider ce serait super.
Cordialement
Mephiston
Bonjour,
pour faire simple j'ai un fichier CSV que j'ouvre que je met dans un array et je souhaite trier cet array sur une colonne, je trouve plein de truc sur internet mais je suis incapable de l'utiliser.
voila mon code :
[php]
$uniqId = $_GET['uniqId'];
$type=$_GET['type'];
$fichier = 'exportCSV/Result'.$type.'_'.$uniqId.'.csv';
$handle = fopen($fichier, 'rb');
$cpt = 0;
while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
if ($cpt!=0)
{
if ($type=='Domaine1')
{
$tab[]=array('legend'=> $data[0], 'ydata' => str_replace('%', '', $data[2]), '$ydata2' => $data[3]);
}
else
{
$tab[]=array('legend'=> $data[0], 'ydata' => $data[4], '$ydata2' => '0');
}
}
$cpt++;
}
array_multisort($tab['ydata'], SORT_NUMERIC, SORT_DESC);
fclose($handle);[/php]
Si vous pouvez m'aider ce serait super.
Cordialement
Mephiston