reciving the url withoguth the page name!

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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

reciving the url withoguth the page name!

Post by pelegk2 »

i want to recive the url but withogut the page name!
for example :
http://localhost/xxx/rrr/234.php
i want only :
http://localhost/xxx/rrr/

how do i do it?>
Hurklefish
Forum Newbie
Posts: 7
Joined: Sat Dec 20, 2003 4:03 pm

one idea..

Post by Hurklefish »

well, you could use a function to split your url into an array (of course, I don't remember the function.. in asp, it's 'split'.. is it 'explode()' in php?)

using the / as the seperator, then loop through the elements of the array one less the the total number of elements, building a new string that doesn't include the final element, 234.php

There's probably a less cumbersome method, but I'll be darned if I can think of it off the top of my head.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

in js its like this :
window.location.toString().substring(0, window.location.toString().lastIndexOf('/')+1)


so i am sure there is something the same in php
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Post Reply