You’re looking for basename
.
The example from the PHP manual:
<?php
$path = "/home/httpd/html/index.php";
$file = basename($path); // $file is set to "index.php"
$file = basename($path, ".php"); // $file is set to "index"
?>
More Related Contents:
- PHP create file with specific name [closed]
- Getting the names of all files in a directory with PHP
- Sanitizing strings to make them URL and filename safe?
- How do I determine the extension(s) associated with a MIME type in PHP?
- The requested URL was not found on this server.
- Grabbing the href attribute of an A element
- How to create a secure mysql prepared statement in php?
- Understanding MVC Views in PHP
- What’s the difference between echo, print, and print_r in PHP?
- How do I create a simple ‘Hello World’ module in Magento?
- Upload a file using PHP
- Get JSON object from URL
- PHP: Check if an array contains all array values from another array
- PHP Add element to every sub array of multi dimension array
- Prevent InnoDB auto increment ON DUPLICATE KEY
- How to prevent PHP sessions being shared between different apache vhosts?
- How to create a random string using PHP?
- PHP get file listing including sub directories
- How to know if MySQLnd is the active driver?
- Create a zip file and download it
- How to solve time out in phpmyadmin?
- jQuery $.ajax request of dataType json will not retrieve data from PHP script
- Laravel 5.4 on PHP 7.0: PDO Exception – Could not find driver (MySQL)
- How to access route, post, get etc. parameters in Zend Framework 2
- Vim inoremap for specific filetypes
- How to properly handle session and access token with Facebook PHP SDK 3.0?
- Browser displays � instead of ´
- What does [\S\s]* mean in regex in PHP?
- Gulp-webapp running BrowserSync and PHP
- PHP Can static:: replace self::?