PHP 4.0 Bug #6504: Explode and split misbehave if multiple separators without values

From: Date: Sat, 02 Sep 2000 18:33:19 +0000
Subject: PHP 4.0 Bug #6504: Explode and split misbehave if multiple separators without values
Groups: php.dev 
Request: Send a blank email to php-dev+get-31673@lists.php.net to get a copy of this message
From: sami@iqs.fi Operating system: Linux 2.2 PHP version: 4.0.1pl2 PHP Bug Type: Misbehaving function Bug description: Explode and split misbehave if multiple separators without values 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().

« previous php.dev (#31673) next »