removing @email.com from string in php

前端 未结 6 1762
感动是毒
感动是毒 2021-01-17 18:00

I want to just get the left half of an email address ( the username part of username@email.com ), so stripping the @ and any characters after it.

6条回答
  •  长发绾君心
    2021-01-17 18:14

    function subStrEmail($Useremail)
    {
        $emailSub=substr($Useremail,4);
        $email = explode('.', $emailSub);
    
        if($email[0]=='www'){
            $email=substr($emailSub,4);
            $email=ltrim($email,'www.');
            return $email;
        }
        return $emailSub;
    }
    

提交回复
热议问题