j'ai modifier mais rien n'y fait...
j'ai modifier mais rien n'y fait...
comme celq on est bien d'accord tu n'as pas le soucis?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 $fp = fopen("Produits.csv", "r"); while($ligne = fgetcsv($fp, 0 ,";")) { echo 'Nom : '.$ligne[0]; } //$val0=array_unique($val0); //foreach($val0 as $val){ //echo 'Nom : '. $val ; // Affichage de la 1re valeur de la ligne }
Non comme ça, cela ne m'affiche pas d'erreur. Mais j'ai les doublon, normal ^^
Le while( ) ne s'arrête jamais => à corriger, voir doc pour exemples.
ok bon alors quelques piste
- tu modifies ton php.ini pour éviter l'erreur ( voir ds un de mes précédents post) car le traitement est trop gourmand
- si tu veux éliminer les doublons du csv définitivement tu traites ton csv avant
- sinon une autre piste trouvé sur php .net
cela reste du bricolage en gros si tu connais la taile maxi de tes lignes cela devraient empêcher l'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using the example above with a length of 1000 will truncate any csv rows longer than 1000 bytes, the remainder of that line will be represented next time you call $data = fgetcsv(). one solution i have seen to this is to use filesize("test.csv") as the length argument, however sometimes with large csv files you may encounter errors for exceeding the memory limit. to remedy this, i have read the csv file into an array, looping through that array to find the longest line in the csv, and then using that value as my length argument, unset($array) to free up the memory. im open to better solutions. <?php $length = 1000; $array = file("test.csv"); for($i=0;$i<count($array);$i++) { if ($length < strlen($array[$i])) { $length = strlen($array[$i]); } } unset($array); $handle = fopen("test.csv", "r"); while ($data = fgetcsv($handle, $length, ",")) { // do what you want with your array here. } fclose($handle); ?>
J'ai réussi a crer les 2 menu mais je ne sais pas comment les lier entre eux.
Partager