function getExt(string $filename): string { if (($i = strrpos($filename, '.')) === false) return ''; return substr($filename, $i + 1); }Using pathinfo() is the offical way but I prefer the above
function getExt2(string $filename): string { return pathinfo($filename, PATHINFO_EXTENSION); }