English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String Character String Functions Manual
The strstr() function is used to return the string from the position of the first occurrence to the end of the string.
strstr(string,search,before_search)
The strstr() function searches for the existence of a string in another string, if it exists, returns the string and the remaining part, otherwise returns FALSE.
Note:This function is binary safe.
Note:This function is case-sensitive. To perform a case-insensitive search, please use stristr() Function.
It returns the remaining part of the string; if the string is not found, it returns false
Serial Number | Parameter and Description |
---|---|
1 | string The string to be searched for |
2 | search The string to be searched |
3 | before_search A boolean value with a default value of "false". If set to "true", it will return the part of the string before the first occurrence of the search parameter. |
Try the following example, searches for the string by the ASCII value of "o" and returns the remaining part of the string
<?php //Searches for the string by the ASCII value of "o" and returns the remaining part of the string: echo strstr("Hello world!",111); echo '<br>'; //Returns the part of the string before the first occurrence of "world" echo strstr("Hello world!","world",true); ?>Test and see‹/›
o world! Hello