I have an array
Array
(
[0] => SamplePictures/Blue hills.jpg
[1] => SamplePictures/Sunset.jpg
[2] => SamplePictures/Water lilies.jpg
[3] => SamplePictures/Winter.jpg
)
at every element of array, you can see the whole path.
I want to remove the Directory name before image like i only want
"blue hills.jpg",Sunset.jpg,Water lilies.jpg,Winter.jpg
How can i do this
Please help in this regard
Eshban
How to remove some string from array
Moderator: General Moderators
Code: Select all
for ($i = 0; $i < count($array); $i++)
{
$array[$i] = str_replace("sampledirectory/", "", $array[$i]);
}or
Code: Select all
$filenames = array_map('basename', $source);- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
This is yet another duplicate of his original thread where he simply refuses to look at basename() in the manual.
eshban: this is getting out of hand. Simply posting the same question 5 times is rude, and is unlikely to prompt someone to write your app for you.
eshban: this is getting out of hand. Simply posting the same question 5 times is rude, and is unlikely to prompt someone to write your app for you.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: