-3

When I use strpos() it is case sensitive. Why? Isn't it not supposed to be?

PHP v5.3.8

$file_check_result = "%PDF-1.6 %âãÏÓ";
$test = strpos($file_check_result, "pdf");
echo $test;

Outputs nothing; if however I change pdf to PDF in strpos it shows position. Why?

Ken White
  • 123,280
  • 14
  • 225
  • 444
JohnA
  • 1,875
  • 8
  • 28
  • 34

2 Answers2

15

stripos is the function that you are looking for. strpos is case sensitive

http://php.net/manual/en/function.stripos.php

Fabrizio
  • 3,734
  • 2
  • 29
  • 32
  • Darn i guess i was too tired because i read "case-insensitive" as case sensitive, i sometimes skip meaning when i read fast... – JohnA Nov 07 '11 at 21:13
4

The case-insensitive one is stripos (note the i):

strpos()   // Finds the position of the first occurrence (case-sensitive)
stripos()  // Finds the position of the first occurrence (case-insensitive)
strrpos()  // Finds the position of the last occurrence (case-sensitive)
strripos() // Finds the position of the last occurrence (case-insensitive)
T30
  • 11,422
  • 7
  • 53
  • 57