php strchr() function


  Translation results:

abbr.character characteristics;chrome chromium;chromium chromium;chromate chromate

php strchr() functionsyntax

Function: Search for the first occurrence of a string in another string.

Syntax: strchr(string,search,before_search);

Parameters:

ParametersDescription
string Required. Specifies the string to be searched for.
search Required. Specifies the string to search for. If the argument is a number, searches for characters that match the ASCII value for that number.
before_searchOptional. The default value is a Boolean value of "false". If set to "true", it will return the portion of the string preceding the first occurrence of the search parameter.

Description: This function is an alias of the strstr() function. This function is binary safe. This function is case-sensitive. To perform a case-insensitive search, use the stristr() function.

php strchr() functionexample

<?php
echo strchr("Hello php.cn!","php");
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

php.cn
<?php
echo strchr("i study php in php.cn!","study");
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

study php in php.cn!

Home

Videos

Q&A