php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6504 Explode and split misbehave if multiple separators without values
Submitted: 2000-09-02 14:33 UTC Modified: 2000-10-02 23:16 UTC
From: sami at iqs dot fi Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.1pl2 OS: Linux 2.2
Private report: No CVE-ID: None
 [2000-09-02 14:33 UTC] sami at iqs dot fi
I have a script that reads tab separated values from a file. It seems that if the file contains multiple tabs without data in between, explode and split return the second tab as the first character of the next string.

E.g:
$str = "text\tsome more\t\teven more";
$vals = explode("\t", $str);

and you get

$vals = array("text", "some more", "\teven more");

I would, of course, expect to get

$vals = array("text", "some more", "", "even more");

This is very annoying, I need to first replace every "\t\t" with something like "\t \t" and then check if some of the values is " " and convert it into "".

The same behaviour is found in split().

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-02 22:52 UTC] sniper@php.net
I can not reproduce this using php4.0.3-dev (latest CVS) in RH6.2 and compiled
as CGI.

--Jani
 [2000-10-02 23:16 UTC] sniper@php.net
No feedback. Can not reproduce.

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 02:01:35 2024 UTC