hi i am using codeigniter in my application .
for my application i need application path only before the last slash
like this
if application path is
http://localhost/elephanti/connections/fb_connection/invite_friends
i want to get
http://localhost/elephanti/connections/fb_connection
it is for a plae like this
echo "<script type='text/javascript'>top.location.href = '"+APPPATH+"'testapp';</script>";
i tried to use '"+APPPATH+"'../testapp' but could not , please help ……………….
If you know the last part will always be the 4th, you can use a “dirty way” like this:
And then:
This will create a valid CI url using only the first 3 segments.
Alternatively, you can use the
uri_string()function, wich returns only the segment part of the url. On this, you can explode/str_replace/array_pop/do whatever you need to and pass the new elaborated string on thesite_url()function wichi will build the correct URL for you.I don’t understand what “testapp” is there or, do you want to substitute the last segment of your url with that? So that you have, in your example,
http://localhost/elephanti/connections/fb_connection/testapp?Keep in mind that both uri_string() and site_url() are functions from the URL helper so you need to load it.