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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Sun May 22 19:03:48 2022 UTC