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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 08:01:29 2025 UTC