php explode command
Explode function in php
How to split a name using explode function?
1. Get the name in a variable
2. Specify the position from which you need to split the name.
3. If you need to split the name after an underscore, use “_”.
4. If you need to split the name after @, use “@”.
[php]
<?php
$name = "john_abraham@gmail.com";
$pieces = explode("_", $name);
echo "firstname = $pieces[0]"."<br />";
$pieces = explode("@", $name);
echo "username = $pieces[0]";
?>
[/php]
Output will be displayed as:
firstname = john
username = john_abraham