check if string has substring php
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}if (strpos($string, 'substring') !== false) {
// do stuff
}$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}$result = strpos("haystack", "needle");
if ($result != false)
{
// text found
}if (strpos($a, 'are') !== false) {
echo 'true';
}$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}
Also in PHP:
- check if value in string php
- case upper php
- Your Composer dependencies require a PHP version ">= 7.2.5". You are running 7.2.0. in
- PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP;
- Class 'App\Http\Controllers\Session' not found
- find lenght string php
- check array is exist
- eloquent where in
- $_redirect() php
- date.now() php
- Demonstrate the use of Loops and arrays in PHP
- clear all cache laravle
- Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 9263312 bytes) in /home/arsalan farooq/local security.uk/wp-includes/wp-db.php
- array_reverse in php example
- CODEIGNITER codeigniter 4 auth
- currentdate timestamp php
- divided by 3 php
- Expression #1 of ORDER BY contains aggregate function and applies to the result of a non-aggregated query laravel
- convert request image as base64 string php
- eloquent timestamps false
- check if row of array exists php
- code to set error for du[licate entry in php
- file_get_contents ssl accpet
- current month date wise how to print in php