php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23939 strpos is case insensitive when it should not be
Submitted: 2003-06-01 13:31 UTC Modified: 2003-06-01 13:56 UTC
From: tony at marston-home dot demon dot co dot uk Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.2 OS: WindowsXP
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: tony at marston-home dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [2003-06-01 13:31 UTC] tony at marston-home dot demon dot co dot uk
$haystack contains "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

so why does $pos = strpos($haystack, 's'); return me the position of 'S' instead of 's'?

If I wanted a case insensitive search I would use stripos instead.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-01 13:49 UTC] philip@php.net
I cannot confirm this:
<?php
$h = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
$p1 = strpos($h,  's');
$p2 = stripos($h, 's');

echo "strpos position $p1 gives me " . $h{$p1};
echo "\n";
echo "stripos position $p2 gives me " . $h{$p2};
?>

Outputs:

strpos position 44 gives me s
stripos position 18 gives me S

Can you double check?

Tested: Linux, PHP 4.3.2 / 5.0.0

 [2003-06-01 13:54 UTC] tony at marston-home dot demon dot co dot uk
Ignore this - I found my mistake.
 [2003-06-01 13:56 UTC] philip@php.net
status->bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC