php - Get only the filename from a path -
i have string
$string = 'c:\folder\sub-folder\file.ext'; i want change to:
$string = 'file.ext'; using php, trying write method ignores left of last \.
use basename() str_replace() \ in path is not recognized basename()
$filename = basename(str_replace('\\', '/', 'c:\folder\sub-foler\file.ext')); echo $filename; // file.ext
Comments
Post a Comment