How to check if string contain specific character in PHP

1 Answer

0 votes
$str = 'PHP Programming';
$ch = 'r';

if (strpos($str, $ch) !== false) {
    echo 'yes';
} else {
    echo 'no';
}



/*
run:

yes

*/

 



answered Mar 26, 2024 by avibootz

Related questions

1 answer 146 views
1 answer 125 views
1 answer 184 views
1 answer 171 views
...