find a specific word in a string php
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}$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:
- display al errros php
- filter only unique string in php
- dmY PHP
- /phpspreadsheet 1.15.0 requires ext-dom * centos yum
- bootstrap carousel foreach loop not working wordpressp php wp
- Fatal error: Allowed memory size of 1073741824 bytes exhausted (trie
- array_unique trong php
- base64 img com php
- check if table exists sql php
- Clear and delete the folder after the time specified in php
- add google analytics to website laravel
- php switch break
- base64 decode
- composer won't use php version for subdomain multiphp
- eloquent firstOrCreate
- consloe.log php
- PHP detect spam name
- create array from string with commas php
- database seeder insert laravel
- Call to a member function diffForHumans() on null (View: C:\xampp\htdocs\basic\resources\views\dashboard.blade.php)
- $age = 20; print ($age >= 18) ? "Adult" : "Not Adult";
- check method type in php
- date_format timeformat php
- acf gutenberg blocks