Chainable native functions and more
$domain = explode('@', 'andre.r.flip@gmail.com');
$domain = end($domain);
$domain = trim($domain);
$domain = with('andre.r.flip@gmail.com')->explode('@', '$$')->end()->trim()->get();
// 'gmail.com'
or
$key = with('some.service.3rdparty.integration')
->explode('.', '!!')
->array_map(function ($value) {
return $value == '3rdparty' ? 'local' : $value;
}, '!!')
->implode('.', '!!')
->get();
// 'some.service.local.integration'
Inspired by Sebastiaan Luca Pipe item