How to get the file extension in PHP? [duplicate]

No need to use string functions. You can use something that's actually designed for what you want: pathinfo():

$path = $_FILES['image']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);

This will work as well:

$array = explode('.', $_FILES['image']['name']);
$extension = end($array);