1

I am using strpos() for search method.. is it possible that it won't be case sensitive...

for example I have this one: this code will always return as False

$val = 'John Wrick';
$sval = 'john';
if(strpos($val, $sval) !== false){
   // code here
}

is it possible that will return the conditinal value into True?

gadss
  • 21,687
  • 41
  • 104
  • 154

3 Answers3

2

you can use strtolower(), strtoupper()

but the best way is to use stripos()

$val = 'John Wrick';
$sval = 'john';
if(stripos($val, $sval) !== false){
   echo "blah blah blah";
}
MI Sabic
  • 367
  • 2
  • 7
  • 18
0

you can use stripos()

Or use strtolower() :

$val = 'John Wrick';
$sval = 'john';
if(strpos(strtolower($val), $sval) !== false){
  echo "sdfsd";
}

see live demo

Community
  • 1
  • 1
Awlad Liton
  • 9,366
  • 2
  • 27
  • 53
0

You can try something like so:

$val = 'John Wrick';
$sval = 'john';
if(strpos(strtoupper($val), strtoupper($sval)) !== false){
   // code here
}