PHP if contains string
$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
echo "My string contains Bob";
}<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}
?>
$a = 'How are you?';
if (strpos($a, 'are') !== false) {
echo 'true';
}// returns true if $needle is a substring of $haystack
function contains($haystack, $needle){
return strpos($haystack, $needle) !== false;
}
Also in PHP:
- clear laravel cache and clear vue
- DISTINCT laravel 5
- check if key exists in array php
- check url parameter if not redirect wordpress
- ->with('success','msj')
- clear cache migration laravel
- db seeder laravel 5
- blade loop last
- Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) php
- file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL
- create orphan token in vault
- clearview cache laravel
- delete duplicate elements array php
- "Allowed memory size of 134217728 bytes exhausted (tried to allocate 56627200 bytes)" in wamp
- base 64 implementation php
- PHP 7.2 extension ext-dom
- event click right mouse
- convert html to pdf php
- check the php version used by composer
- find strign in string in php
- date add in php days
- check if specific index of array exist php
- delete all laravel cache
- Redirect::route('profile') and with() in laravel