|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
45 - 20 = ?
Subscribe to this entry?

 [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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-01 13:49 UTC]
I cannot confirm this:
$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};


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]
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Oct 04 08:01:25 2023 UTC