PHP function to get everything after a given value in a string str_after()

The str_after() function returns everything after a given value in a string. Sticking with the email example, let’s say we wanted just to grab the hostname from an email.

Source Code:

function str_after($subject, $search)
{
    if ($search == '') {
        return $subject;
    }
    $pos = strpos($subject, $search);
    if ($pos === false) {
        return $subject;
    }
    return substr($subject, $pos + strlen($search));
}

This function is also available in Laravel 5.4 as helper Str::after().

Output / Usage:

<?php 

$email = 'eduzip@example.com';

echo str_after($email, '@');

# -> example.com

Comments: (Your feedback is valuable to us)