ID: 37048 Updated by: [EMAIL PROTECTED] Reported By: gtg782a at mail dot gatech dot edu -Status: Open +Status: Bogus Bug Type: Strings related Operating System: RH 7.3 PHP Version: 5.1.2 New Comment:
RTFM "If the split_length length exceeds the length of string, the entire string is returned as the first (and only) array element." Previous Comments: ------------------------------------------------------------------------ [2006-04-12 02:37:55] gtg782a at mail dot gatech dot edu Description: ------------ In the lastest version of PHP (5.1.2), running str_split with an empty string returns an array containing a single element, which is also an empty string. This seems counterintuitive and is a different result than in previous versions of PHP5. Rather than return a single-element array with an empty string, I would expect an empty array with no elements. (5.0.4 evaluates in the latter way - giving the more intuitive result). This makes a difference when the resulting array is used as the argument to foreach, for example, such as foreach(str_split($string) as $letter). If a string is empty, it would be intuitive that foreach would never execute its inner code. If this is an intended behavior, then the version difference ought to be noted in the documentation. I do think, however, that the old behavior made more sense. Reproduce code: --------------- var_dump(str_split("")); Expected result: ---------------- array(0) { } Actual result: -------------- array(1) { [0]=> string(0) "" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37048&edit=1