English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String manual of string functions
The strchr() function is used to find the first occurrence of a string in a string.
strchr(string,search,before_search);
It is used to search for the first occurrence of a string in another string
Note: This function is case-sensitive. For a case-insensitive search, please use stristr() Function.
It returns the remaining string
Serial number | Parameter and description |
---|---|
1 | string Required. Specify the string to be searched. |
2 | search Required. Specify the string to be searched. If this parameter is a number, it will search for the character corresponding to the ASCII value of the number. |
3 | before_search Optional. 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 to find the first occurrence of "PHP" in "Hello PHP!":
<?php //Find the first occurrence of "PHP" in "Hello PHP!" and return the rest of the string found: echo strchr("Hello PHP!","PHP"); ?>Test and see‹/›
Output result
PHP!