PHP Function to Calculate the Salesforce 15 Character ID to 18 Charachter ID

function salesForceIdCalculate($id)
{
    $map      = implode('', array_merge(range('A', 'Z'), range(0, 9)));
    $checksum = '';
    
    foreach (str_split($id, 5) as $chunk) {
        $checksum .= substr($map, bindec(strrev(array_reduce(str_split($chunk, 1), function($carry, $item)
        {
            $carry .= (!is_numeric($item) && $item == strtoupper($item)) ? '1' : '0';
            return $carry;
        }, ''))), 1);
    }
    
    return $checksum;
}

// example
//$_15ID = '0019000001EJNfj';
//$_18ID = $_15ID. salesForceIdCalculate($_15ID);