从yii2中的电子邮件地址中提取数字部分

I have an email address format like this - st15103@live.tees.ac.uk what i want to do is extract the ID part of this email like this - st15103 How can i do this using PHP string function ?

Just split on @ and get the first part ?

$id = array_shift( explode("@", " - st15103@live.tees.ac.uk") );

It's Simple explode it.

<?php
$id = explode('@',t15103@live.tees.ac.uk)[0];
echo $id;
?>

Hope this helps you