search the sign from end of a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mit
Forum Commoner
Posts: 32
Joined: Mon Sep 15, 2008 6:37 am

search the sign from end of a string

Post by mit »

I ve to search the / (slash ) from the end in this url address: http://localhost/Projects/admin/uploadlist.php and change it to http://localhost/Projects/admin/resized/uploadlist.php , so first need to find the / and then add resized/ to it , can any one help me?
i ve found this but not helping me ;
$url= 'http://localhost/Projects/admin/uploadlist.php ';
$newurl= strstr($url, '/');
efortis
Forum Newbie
Posts: 7
Joined: Mon Oct 13, 2008 7:48 pm

Re: search the sign from end of a string

Post by efortis »

The simplest way str_replace('/admin','/admin/resized/',$url);
ugly but it will work if that only the problem
mit
Forum Commoner
Posts: 32
Joined: Mon Sep 15, 2008 6:37 am

Re: search the sign from end of a string

Post by mit »

thx a lot , this one works, but what if i want to search the / from the end of this url like
http://localhost/Projects/admin/uploadlist.php and then change it to http://localhost/Projects/admin/resized/uploadlist.php , meaning search last / and add "resized/" after it
Post Reply