I have problem with checking if part of string is containing other string but strpos and stripos are not working for me.
The case that I need to check if word pris is containing in string -med prista-
Any suggestions?
In PHP 8 you have a new function called str_contains() created for this purpose:
if (str_contains('-med prista-', 'pris')) {
echo "Found!";
}
If you are using older PHP versions then you can use mb_strpos (multibyte), or strpos functions like this:
if(mb_strpos('-med prista-', 'pris') === false){
// not found
} else {
echo "Found!";
}
strposisn't working for checking the possible position of a substring in a string, it means you are doing something wrong, and should refer to the manual (and/or post the code that isn't working): php.net/strpos