PHP String Exercises: Get the filename component of the specified path
PHP String: Exercise-13 with Solution
Write a PHP script to get the filename component of the following path.
Sample path : "https://www.w3resource.com/index.php"
<?php $path = 'www.example.com/public_html/index.php'; $file = basename($path, ".php"); echo $file."\n"; ?>
PHP Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?