For Example let the path be, $path = "protected/musics/composer/album/song.mp3"; I can extract the file name with the use of basename() function. $path = basename($path, ".mp3"); Also I want to extract the last two directory names in a variable example $composer_name = composer //(extracted from the path $path); $album_name = album //(extracted from the path $path) Could you please someone help me out of this? Thanks in advance.
isnt your path wrong $path = "protected/musics/composer/album/song.mp3"; ??? use this http://getid3.sourceforge.net/
<?php $path = "protected/musics/composer/album/song.mp3"; //output an array... print_r(explode("/", $path)); ?> PHP: Also take alook at http://php.net/manual/en/function.pathinfo.php