Home >Backend Development >PHP Problem >What is the usage of strstr function in php
The usage of strstr function in php is to search whether a string exists in another string, such as [strstr("Hello world!",111);]. If present, the function returns the string and the remainder.
The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.
strstr() function searches whether a string exists in another string. If so, returns the string and the remaining part, otherwise returns FALSE.
For example, search the string through the ASCII value of "o" and return the remaining part of the string
<!DOCTYPE html> <html> <body> <?php echo strstr("Hello world!",111); ?> </body> </html>
Running result:
o world!
For example, we want to return " world" The string part before the first appearance
<!DOCTYPE html> <html> <body> <?php echo strstr("Hello world!","world",true); ?> </body> </html>
Running results:
Hello
Related video tutorial sharing: php video tutorial
The above is the detailed content of What is the usage of strstr function in php. For more information, please follow other related articles on the PHP Chinese website!