Example 1 — Get Text from the First Match
Split an email at the @ sign.
<?php
$email = "[email protected]";
echo strchr($email, "@"), PHP_EOL;
echo strchr($email, "@", true), PHP_EOL; How It Works
- Search for @. It is found at position 4.
- Default result. You get the match and everything after it.
- Add true. You get only the part before the match.
- Same as strstr(). strchr() is just another name.

