I'm trying to use the split function to identify the extension of an
uploaded file:

   $file_name = $_FILES['userfile']['name'];
   $pieces = explode(".", $file_name);
   $file_extension = $pieces[1]; // piece2

Which will work, providing that the uploaded file only has one full-stop in
the name (so 'thisfile.pdf' will return 'pdf' as the $file_extension, for
example.)

However, there is a chance that someone will try and upload a file which has
more than one full-stop in it (eg. 'this.file.pdf') which will of course
return 'file' as the variable $file_extension.

My question is, is there any way to determine what the *last* result of the
array is rather than working from the first?

This may be a basic question, but I'm a newbie; apologies in advance if this
is a simple one. I'm using PHP4, BTW, if that makes a difference.

Cheers

Russell

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to