$str=10,11,12,13,14,15,16,17,18,19;
$str2=9;
I want to determine whether this $str2 is in $str, but I can still find it using PHP’s own function strpos because 19 also contains 9. The effect I want is to judge whether each string is equal to this $str2 by commas. Please help me. Thank you. Endless^_^
$str=10,11,12,13,14,15,16,17,18,19;
$str2=9;
I want to determine whether this $str2 is in $str, but I can still find it using PHP’s own function strpos because 19 also contains 9. The effect I want is to judge whether each string is equal to this $str2 by commas. Please help me. Thank you. Endless^_^
First separate the elements into an array by commas and use the explode() function. Then use the in_array() function to find out whether there is an element 9.
Remove the separator (comma) to only one element, and then use stripos. Note that the possible position is 0, so use === false