realcoder Posted November 15, 2010 Share Posted November 15, 2010 hi i am a making a site in which m saving a songs information in database then fetching that out for inserting song link m using readdir function that read all song in a folder then save them in database but i have problem when that read file name .mp3 also include with that which i don't want to show on page where i fetch that mean simply i want that i can insert song name separately and file separately... and i want to use readdir also for getting file name becoz that easy way instead of upload through panel ..? any idea or solution about adding separately file name Quote Link to comment https://forums.phpfreaks.com/topic/218707-reading-folder/ Share on other sites More sharing options...
realcoder Posted November 15, 2010 Author Share Posted November 15, 2010 after writing this code $dir = "A Flat"; $open = opendir($dir); while(false !== ($read = readdir($open))){ if($read != '.' && $read != '..'){ echo $read."<br />";} } out is this 01 - Meetha Sa Ishq.mp3 02 - Dil Kashi.mp3 03 - Chal Halke Halke.mp3 04 - Pyar Itna Na Kar.mp3 05 - Meetha Sa (unplugged).mp3 06 - Dil Kashi.mp3 07 - Meetha Sa (partymap mix).mp3 full file name i will insert these data in table song in link column but i need also the name of songs for inserting in name colum which i show on page to show people name of songs because if the same name i put in name field so .mp3 will be with every name that will not look good so how i add also separete name of these songs which will be in directory Quote Link to comment https://forums.phpfreaks.com/topic/218707-reading-folder/#findComment-1134380 Share on other sites More sharing options...
salathe Posted November 15, 2010 Share Posted November 15, 2010 You can use some of the string functions to take away the parts that you don't want, basename to remove the .mp3 and/or maybe a regular expression to do everything at once, if you've used those before. Quote Link to comment https://forums.phpfreaks.com/topic/218707-reading-folder/#findComment-1134391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.