check for a word in a string php
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}if (strpos($haystack,$needle) !== false) {
echo "$haystack contains $needle";
}
Also in PHP:
- check if array has value php
- Warning: func_get_arg() expects exactly 1 parameter, 0 given in
- filter laravel
- current date & tie in php
- explode in php
- composer install larave
- datetimepicker format php
- echo ternary php
- display error
- check if substring exists in string php\
- can we find like directorries in php
- error reporting phpp
- cache clear laravel dosent work
- : 1071 Specified key was too long; max key length is 767 bytes (SQL: alter tabl e `users` add unique `users_email_unique`(`email`))
- convert string to uppercase in php
- .htaccess codeigniter
- <?php function pre_r($array){ echo '<pre> print_r($array); echo</pre>>'
- date with time in php
- create auto image path folder in laravel 8
- array if key exist php
- check if a word exist in a string php
- array uniuq in php
- echo error in php
- fetch body show in php code