/    Sign up×
Community /Pin to ProfileBookmark

explode() and PHP_SELF

$curr_loc = $_SERVER[‘PHP_SELF’];
$root_array = explode(‘/’, $curr_loc);
echo $root_array[0];

The idea is that I find the current location and seperate the parts by “/”. I would then go through the array and see if anything is there beyond the actual page I was on, and if so, I could use it to find the current folder I am using and for other stuff. Currently, the last line returns nothing even though I am looking at a page in a subfolder.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Bootsman123Jul 11.2005 — Why don't you test it then:
[code=php]
echo $_SERVER['PHP_SELF'];
[/code]


You might need something like this:

http://nl3.php.net/manual/en/function.dirname.php

http://nl3.php.net/manual/en/function.basename.php

There are several example explaining what you want.
Copy linkTweet thisAlerts:
@spufiauthorJul 12.2005 — The fourth line in the code(not posted) was to echo PHP_SELF to make sure it was correct. Those file functions were what I was looking for. One answers my current question and the other answers a future question, so thanks.
×

Success!

Help @spufi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...