function findexts ($filename)This function is used to find the file extension. If you wanted to rename a file upload you would still need to keep the extension. We can use this function to find it. Once found it can be appended to the end of a random number or a timestamp (or other naming system you choose) to use as the file name.
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
Basically what the code is doing is first using strtolower to change the extension (and the whole file name) into lower case, just to keep it clean. Next we are splitting the filename into an array using split. By splitting it at the [.] the extension will be the last element in the array, which we then return.

