Using strrpos () with PHP
Possible duplicate:
How to make strpos case insensitive
I check to see if the string contains the text "People who love". Well the code works great! Moreover, it is case sensitive. What can I do to prevent this?
If the string "people who like to run" it returns false If the string "People who like to run" it returns true
I want this to be not case sensitive.
code:
<?php
$string = "People who like to run";
if (strrpos($string, 'People who like') === false) {
echo "False";
}
else {
echo "True";
}
+3
Matt
source
to share
3 answers
See strripos
, case insensitive version strrpos
.
+12
nice ass
source
to share
use strripos instead
OR
use strtolower on line before testing
$string = "People who like to run";
if (strrpos(strtolower($string), strtolower('People who like')) === false) {
echo "False";
}
else {
echo "True";
}
+9
Ethan
source
to share
Use strripos for case insensitivity
+4
Yoni hassin
source
to share