PHP 8.5.0 Alpha 1 available for testing

Voting

: four minus one?
(Example: nine)

The Note You're Voting On

cristian dot ban at neobytesolutions com
18 years ago
regarding note from rehfeld dot us :

In my experience the best( and easiest ) way to find the extension of a file is :

<?php

// use this when you are sure it actually has an extension.
$extension = end(explode(".", $file_name));

?>

or

<?php

// this one will also check if it actually has an extension
$parts = explode(".", $file_name);
if (
is_array($parts) && count($parts) > 1)
$extension = end($parts);

?>

<< Back to user notes page

To Top