Ok, I have a file listing script, and it saves all the files in an array called $file
I'd like it to remove .mp3 from the filenames when it displays them, I just need some code that will go through the array $file and replace each .mp3 part of the aray with nothing.
Replace parts of an array
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
array_filter() may be of interest.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Sorry, I understood you wanted to remove the entries, not just rename them. array_map() and array_walk() can be used for what you wish.
Thanks, none of your stuff worked. This worked:
I don't think you understood what I wanted to do, but I found out how myself. Thanks anyway.
Code: Select all
$newarray = str_replace(".mp3", "", $file);