Home > Article > Backend Development > PHP implements the method of finding substrings in a specified string_PHP tutorial
This article mainly introduces the method of PHP’s method of finding substrings in specified strings, involving strpos in PHP The technique of searching strings using () function has certain reference value. Friends who need it can refer to it
The example in this article describes the method of finding substrings in a specified string in PHP. Share it with everyone for your reference. The specific analysis is as follows:
The strpos() function can be used to find substrings in php. The strpos() function will try to find the first occurrence of a substring in the source string. If found, it returns a non-negative integer indicating the position of the substring. Otherwise it returns a boolean false.
?
3 4
5
6
9 10 11 |
print("pos1 = ($pos1); type is " . gettype($pos1) . "n"); print("pos2 = ($pos2); type is " . gettype($pos2) . "n");
<🎜>print("pos3 = ($pos3); type is " . gettype($pos3) . "n");<🎜>
<🎜>?>
|
1 2 3 | pos1 = (13); type is integer pos2 = (0); type is integer pos3 = (); type is boolean |