get a file name from a path.
Posted: Tue Sep 02, 2003 5:14 am
Hi,
I have to write a function that takes the path and gets the file name
the path can come in this format:
'c:\\folderA\\folderB\\folderC\\folderZ\\file.txt'
Or in that format:
'c:/folderA/folderB/folderC/folderZ/file.txt'
Here is the script I use now:
preg_match('/([^\\\\]*(?!\\\\))$/', $path, $match);
$result = array_unique ($match);
print_r($result);
but it helps only for the first case. how can I write a small script that handle both?
Thanks
I have to write a function that takes the path and gets the file name
the path can come in this format:
'c:\\folderA\\folderB\\folderC\\folderZ\\file.txt'
Or in that format:
'c:/folderA/folderB/folderC/folderZ/file.txt'
Here is the script I use now:
preg_match('/([^\\\\]*(?!\\\\))$/', $path, $match);
$result = array_unique ($match);
print_r($result);
but it helps only for the first case. how can I write a small script that handle both?
Thanks