php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44427 stripos() and strpos() do not return false when needle is not found
Submitted: 2008-03-13 10:31 UTC Modified: 2008-03-13 12:38 UTC
From: garichner at i2pmail dot org Assigned:
Status: Closed Package: Strings related
PHP Version: 5.2.5 OS: S.u.S.E. 10.3
Private report: No CVE-ID: None
 [2008-03-13 10:31 UTC] garichner at i2pmail dot org
Description:
------------
stripos strpos don't do false on needle not found

foreach ($buffer_Infile1 as $VAL1) {
    	        foreach ($VAL1 as $VAL2){
    	            $VAL2=trim($VAL2);
    	            $POSP=stripos($VAL1[0],".");
    	            echo $VAL2." ".$POSP."\n";
    	        }
does this

s.schaefer 1
sschaefer 1

but should to this

s.schaefer 1
sschaefer 0


Reproduce code:
---------------
foreach ($buffer_Infile1 as $VAL1) {
    	        foreach ($VAL1 as $VAL2){
    	            $VAL2=trim($VAL2);
    	            $POSP=stripos($VAL1[0],".");
    	            echo $VAL2." ".$POSP."\n";
    	        }

Expected result:
----------------
s.schaefer 1
sschaefer 0

Actual result:
--------------
s.schaefer 1
sschaefer 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-13 11:54 UTC] jani@php.net
Please provide a short but _complete_ reproducing script. (one that starts with <?php, ends with ?> and can be simply copy'n'pasted to run.
 [2008-03-13 12:38 UTC] garichner at i2pmail dot org
foreach ($buffer_Infile1 as $VAL1) {
    	        foreach ($VAL1 as $VAL2){
    	            $VAL2=trim($VAL2);
    	            $POSP=stripos($VAL2,".");//<<<<<<<<
    	            echo $VAL2." ".$POSP."\n";
    	        }

this is the output 

s.schaefer 1
sschaefer

solved
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 16:01:36 2024 UTC