Skip to content

php SplFileObject and the difference between fgetcsv and current

I had to investigate a bug and figured out a strange behavior in the SplFileObject implementation of php. I know, some of you would add "again", but this does not matter.
To illustrate this problem, I created a little example file. If you run it, you get the following output:


generating content.
..........
writing content.
..........
using fgetcsv and writing key 13 times.
0 0 1 2 3 4 5 6 7 8 9 10 10 
using current and writing key 13 times.
0 0 0 0 0 0 0 0 0 0 0 0 0

As you can see, if you use "fgetcsv", the current key is move to the next step.
If you use "current", the current key won't get updated (which is most likely what you want).
You can easily set the csv delimiter etc. by using setCsvControl()".

Trackbacks

Keine Trackbacks

Kommentare

Ansicht der Kommentare: Linear | Verschachtelt

Noch keine Kommentare

Die Kommentarfunktion wurde vom Besitzer dieses Blogs in diesem Eintrag deaktiviert.

Kommentar schreiben

Die angegebene E-Mail-Adresse wird nicht dargestellt, sondern nur für eventuelle Benachrichtigungen verwendet.
Um einen Kommentar hinterlassen zu können, erhalten Sie nach dem Kommentieren eine E-Mail mit Aktivierungslink an ihre angegebene Adresse.

Um maschinelle und automatische Übertragung von Spamkommentaren zu verhindern, bitte die Zeichenfolge im dargestellten Bild in der Eingabemaske eintragen. Nur wenn die Zeichenfolge richtig eingegeben wurde, kann der Kommentar angenommen werden. Bitte beachten Sie, dass Ihr Browser Cookies unterstützen muss, um dieses Verfahren anzuwenden.
CAPTCHA

Markdown-Formatierung erlaubt
Formular-Optionen