Php strchr
From w3cyberlearnings
Contents |
PHP function strchr
This function finds the first occurrence of a string, and it is the alias of strstr() function.
Syntax strchr
- string: string to be used for search
- search: list of string to search for, if ASCII number will force to search the ASCII value.
- before_handler (option): if set to true return the part of the haystack before the first occurences
strchr(string, search,before_handler)
Example 1
<?php $email = "[email protected]"; $domain = strchr($email, 64,true); echo $domain; ?>
Output
bob200
Example 2
- Match using the ASCII number.
- The ASCII number convert to the ASCII value.
- ASCII value 64 is '@' sign.
<?php $email = "[email protected]"; $domain = strstr($email, 64); echo $domain; ?>
Output
@w3cyberlearnings.com