We have:
$path = "/home/httpd/html/index.php";
$file = basename($path); // $file is set to "index.php"
$file = basename($path, ".php"); // $file is set to "index"
$file = 'index'; // the result
How can we query a multiple file extensions? Instead of
$file = basename($path, ".php");
something like
$file = basename($path, ".php,gif,png,jpeg,css,js,html");
So, If $path = "/home/image.png";
$file
will get value 'image'.
I've tryed to use pathinfo()
and [filename]
, but my server doesn't support PHP 5.2.
$file = basename($path);
$info = pathinfo($file);
$name = basename($file,'.'.$info['extension']); // index
if you using PHP > 5.2.0
$info = pathinfo('/www/awesomepath/index.php');
$name = $info['filename']; //index
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With