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
get a file name from a path.
Moderator: General Moderators
I think the PHP function basename() will help you out a bit.