tags:

views:

597

answers:

4

For example,how to get Output.map from F:\Program Files\SSH Communications Security\SSH Secure Shell\Output.map

with PHP?

+4  A: 

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"
?>
Mark Rushakoff
A: 
$filename = basename($path);
p4bl0
A: 

Hi,

The basename function should give you what you want :

Given a string containing a path to a file, this function will return the base name of the file.

For instance, quoting the manual's page :

<?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"
?>

Or, in your case :

$full = 'F:\Program Files\SSH Communications Security\SSH Secure Shell\Output.map';
var_dump(basename($full));

You'll get :

string(10) "Output.map"
Pascal MARTIN
A: 

You can use basename() function

Vertigo