php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33378 The explode() function doesn't work properly when using "+" as the separator
Submitted: 2005-06-17 05:02 UTC Modified: 2005-06-17 09:49 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: mbrown at dxsonline dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.0.4 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mbrown at dxsonline dot com
New email:
PHP Version: OS:

 

 [2005-06-17 05:02 UTC] mbrown at dxsonline dot com
Description:
------------
The explode() function will not properly separate strings that are separated by plus signs (+). It will put all of the string into the first array element separated by spaces.

Reproduce code:
---------------
$toExplode = "1+1+1+1";
$exploded = explode("+", $toExplode);

foreach($exploded as $e) {
echo "Bug: ".$e."<br />"; }

Expected result:
----------------
Bug: 1
Bug: 1
Bug: 1
Bug: 1

Actual result:
--------------
Bug: 1 1 1 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-17 09:49 UTC] helly@php.net
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

Works like a charne:
$ php -r 'var_dump(explode("+", "1+2+3+4"));'
array(4) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
  [2]=>
  string(1) "3"
  [3]=>
  string(1) "4"
}

Since your output does not contain the '+' sign you obviously executed the code through a browser in which case the output is absolutley exected since the '+' are converted to spaces before your script sees them.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 09:01:27 2025 UTC