Page 1 of 1

search the sign from end of a string

Posted: Mon Oct 13, 2008 10:00 pm
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, '/');

Re: search the sign from end of a string

Posted: Mon Oct 13, 2008 10:09 pm
by efortis
The simplest way str_replace('/admin','/admin/resized/',$url);
ugly but it will work if that only the problem

Re: search the sign from end of a string

Posted: Mon Oct 13, 2008 10:16 pm
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