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
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: garichner at i2pmail dot org
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC