Re: How can I solve this?
| From: | Julien Bonastre | Date: | Wed, 18 Jan 2006 20:59:06 +0000 |
| Subject: | Re: How can I solve this? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41067@lists.php.net to get a copy of this message | ||
Two alternatives..
dirname(); returns basically just the path, same string as using pathinfo["dirname"] but saves that array step..
or back to the love of my life [well, the non-human one]:
preg_replace("/^\/?(.*)\/[\w]+\.php$/","$1",$PHP_SELF)
that strips that leading forward slash too ;-)
by love of my life I mean, Regular Expressions, not that particular one :P
ciao
----- Original Message ----- From: "Chris Payne" <cjp@planetoxygene.com>
To: <php-db@lists.php.net>
Sent: Thursday, January 19, 2006 3:58 AM
Subject: RE: [PHP-DB] How can I solve this?
Wonderful thank you, it displays a single / before the dir name but I can remove that without too much trouble :-) Thank you. Chris try $x =pathinfo($_SERVER['PHP_SELF']); echo $x['dirname']; =C= | | Cal Evans | http://blog.calevans.com | | Chris Payne wrote:-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.14.20/234 - Release Date: 18/01/2006Hi everyone, I am using PHP_SELF in order to get the current path on a dynamically created webpage. This gives me the following: /my_website/index.php My problem is, ALL I NEED is the directory name - no / or no index.php,howcan I strip these out to leave JUST the folder name the file is locatedin?I need this because the page is dynamically created, and it gets templated information from a database and needs to use the foldername as the identifier between the DB entry to use for grabbing the information andthepages inside the directory. Any help would be really appreciated and I'm certain it's something REALLY obvious. Chris-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 267.14.20/233 - Release Date: 18/01/2006