Q:

Write a PHP script to extract the file name from the following string

0

Write a PHP script to extract the file name from the following string.

Sample String : 'www.example.com/public_html/index.php'

Pictorial Presentation:

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$path = 'www.example.com/public_html/index.php';
$file_name = substr(strrchr($path, "/"), 1);
echo $file_name."\n"; // "index.php"
?>

Sample Output:

index.php

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now