Home>Article>Backend Development> How to extract username of email address in php? (code example)

How to extract username of email address in php? (code example)

藏色散人
藏色散人 Original
2018-11-06 11:38:43 5836browse

This article mainly introduces how to usePHP to extract the usernameof an email address.

In our daily PHP learning process, extracting a certain piece of content from a string is a very common knowledge point, and everyone must be very familiar with it.

For novices, it is easy to learn as long as they master the relevant functions.

Recommended reference PHP video tutorial: "PHP Tutorial"

Let's use a simple example to introduce how to extract the username of an email in PHP.

The code example is as follows:


      

Here we are getting the user name from the email address "rayy@example.com", that is, extracting the string before the @ symbol.

The results of accessing through the browser are as follows:

How to extract username of email address in php? (code example)

#The strstr function means to find the first occurrence of a string, that is, the strstr function searches for a string in another string appears for the first time in . The return value is part of the returned string or FALSE if the needle is not found.

Then we can also express it through a simple flow chart:

How to extract username of email address in php? (code example)

This article is about the specific method of extracting the user name of the email address with PHP The introduction is very simple and easy to understand. I hope it will be helpful to novice friends!

The above is the detailed content of How to extract username of email address in php? (code example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn