I am wondering how to complete multiple strpos checks.
Let me clarify:
I want strpos to check the variable "COLOR" to see if any numbers from 1 to 8 are anywhere in the variable. If any numbers from 1 to 8 are present, I want to echo "selected".
Examples:
Let's say only the number 1 is in the variable, it will echo "selected".
Let's say the numbers 1 2 and 3 are in the variable, it will echo "selected."
Let's say the numbers 3 9 25 are in the variable, it will echo "selected" (because of that 3!!).
Let's say only the number 9 is in the variable, it will NOT echo.
Let's say the numbers 9 25 48 are in the variable, it will NOT echo.
strpos in PHP is a built-in function. Its use is to find the first occurrence of a substring in a string or a string inside another string. The function returns an integer value which is the index of the first occurrence of the string.
The strpos() function finds the position of the first occurrence of a string inside another string. The stripos() function finds the position of the first occurrence of a string inside another string. 2. It is case-sensitive function.
Return Value: Returns the position of the first occurrence of a string inside another string, or FALSE if the string is not found.
try preg match for multiple
if (preg_match('/word|word2/i', $str))
strpos() with multiple needles?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With