php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14658 The strtok() changes destroyed 4 years old applications!
Submitted: 2001-12-22 05:46 UTC Modified: 2001-12-22 06:55 UTC
From: hofmann at hofmann-int dot de Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.1.0 OS: Linux, Solaris, Windows
Private report: No CVE-ID: None
 [2001-12-22 05:46 UTC] hofmann at hofmann-int dot de
The change made in 4.1.0 to strtok() destroyed my applications from the past 4 years!
Thats because I used strtok() to read data from CSV (comma separated values) files - for which it works perfektly!
For CSV (not only separated with commans - also with | and other symbols) it is required that EMPTY fields will be reported as empty field!!! So the change you made brokes my existing applications.

For parsing tokens as explained I understand the change - because there you wont need empty tokens!
But for real parsing strtok is useless(!) because you always have more than one separator - for
human language parsing you need space, return/line feed, full stop as well as comma, questionmark etc. as separators! strtok() fails here as it seems to me!!!

So my suggestion ist - to restore the old behaviour for CSV parsing and adding a new command like
strparse() that will work with a list of separators!!!


Greetings

Dipl.-Inform. Kai Hofmann

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-22 06:55 UTC] derick@php.net
We are aware of this situation, and after some discussion on the mailinglist, we will not change it back.
However, to read CSV files, there is function fgetcvs (http://www.php.net/manual/en/function.fgetcsv.php) which should do exactly what you want.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 09:01:30 2024 UTC