php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60589 str_replace error
Submitted: 2011-12-21 21:02 UTC Modified: 2011-12-22 07:12 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: pehohlva at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.8 OS: lenny debian
Private report: No CVE-ID: None
 [2011-12-21 21:02 UTC] pehohlva at gmail dot com
Description:
------------
str_replace() error:

following construct delivers true on using phpexcelreader on ms excelfile  as 
$item if $item = ord($item)=32

that means, not all whitespaces where found with str_replaces()




Test script:
---------------
foreach($user as $key=>$item)
            {
              if(trim(str_replace(" ","",$item)) == "")
              {
                 
                  echo"<br>items:".ord($item);
              }
          }


output will be displayed with ascii 32 (space). Should be not possible.

Expected result:
----------------
dump->NULL

Actual result:
--------------
" " (space ascii 32

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-21 21:07 UTC] pehohlva at gmail dot com
meant is: str_replace() doesnt recognise ascii 32 as whitespace / space.
 [2011-12-22 02:32 UTC] anon at anon dot anon
str_replace works fine. You're just not using its result. str_replace returns the altered string; it doesn't change the original. Do:
$item = str_replace(" ", "", $item);
 [2011-12-22 07:12 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-12-22 07:12 UTC] cataphract@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 13:01:35 2025 UTC