w3resource
php Programming Exercies

PHP String Exercises: Extract the user name from the specified email ID

PHP String: Exercise-6 with Solution

Write a PHP script to extract the user name from the following email ID.

Sample String : '[email protected]'

Pictorial Presentation:

PHP String Exercises: Extract the user name from the specified email ID

Sample Solution:

PHP Code:

<?php
$mailid  = '[email protected]';
$user = strstr($mailid, '@', true);
echo $user."\n";
?>

Sample Output:

rayy

Flowchart:

Flowchart: Extract the user name from the specified email ID

PHP Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP script to extract the file name from the specified string.
Next: Write a PHP script to get the last three characters of a string.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming


bedava porno