iSimpleDesign
iSimpleDesign

Reputation: 403

Preg_match PHP Folders

Can someone please show me how i can preg_match this so that it just shows the file name??

Music/dnb/Crazy Talk_Tantrum Desire_192.mp3

show it will just show.

Crazy Talk_Tantrum Desire_192.mp3

Having a right pain trying to get this to work, wasting far too much time on it any help please???

Upvotes: 0

Views: 471

Answers (1)

zerkms
zerkms

Reputation: 255015

$name = basename('Music/dnb/Crazy Talk_Tantrum Desire_192.mp3');

if you're insisting on using regexps it could be:

preg_match('~/([^/]+)$~', 'Music/dnb/Crazy Talk_Tantrum Desire_192.mp3', $matches);
var_dump($matches[1]);

Upvotes: 4

Related Questions