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


source to share


3 answers


See strripos

, case insensitive version strrpos

.



+12


source


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


source


Use strripos for case insensitivity

+4


source







All Articles