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
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:
MUST BE VALID
Solve the problem:
46 - 9 = ?
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.

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: Thu Apr 18 21:01:29 2024 UTC