- implode: documentation ( source)
- explode: documentation ( source)
<?php
$sep = '.';
$str1 = 'email@test.com.robot';
$str2 = 'email@test.fr.uk.robot';
$get1 = explode($sep,explode('@',$str1)[1]);
$get2 = explode($sep,explode('@',$str2)[1]);
echo implode($sep,[$get1[0],$get1[1]]);
echo PHP_EOL;
echo implode($sep,[$get2[0],$get2[1]]);
?>