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.
try preg match for multiple
strpos() with multiple needles?
If all value is seperated by a space in value then you can do the following. Otherwise ignore it.
It is needed because if you have
$color="25";
thenstrpos
will found both 2, 5 and 25 so required result will not comeI found the above answers incomplete and came up with my own function:
Usage:
I just used the OR statement (||)