ID: 48692 Updated by: j...@php.net Reported By: estudiosima at gmail dot com -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: ubuntu 8.04 PHP Version: 5.2.10 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2009-06-25 19:59:03] sjoerd-php at linuxonly dot nl Thank you for your bug report. The behavior you describe is by design. If there are n delimeters, explode() returns n+1 elements. It splits the string using a space, and thus also splits using the first space. Because there is nothing before the first space, the first element of the array is empty. In this case, you can first trim() the string to remove spaces. ------------------------------------------------------------------------ [2009-06-25 13:42:59] estudiosima at gmail dot com Description: ------------ if the string have a space in the begin of the string, takes the space as a word. Reproduce code: --------------- --- >From manual page: function.explode --- <? phpinfo(); $a = " word1 word2"; $b = explode(" ",$a); print_r($b); print "<br>".count($b); /* result: Array ( [0] => [1] => word1 [2] => word2 ) 3 */ ?> Expected result: ---------------- Array ( [0]=>word1 [1]=>word2 ) Actual result: -------------- Array ( [0] => [1] => word1 [2] => word2 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48692&edit=1