Re: help condensing regular expressions
| From: | Julio Nobrega Trabalhando | Date: | Fri, 05 Apr 2002 20:26:06 +0000 |
| Subject: | Re: help condensing regular expressions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-91793@lists.php.net to get a copy of this message | ||
How about:
$site_root = '/www/user/htdocs/';
<img src="<?php echo $site_root; ?>images/logo.png" />
Instead of going relative, go from the root. Or you could put $site_root
as your url:
$site_root = 'http://www.your_site.com/';
--
Julio Nobrega.
Um dia eu chego lá:
http://sourceforge.net/projects/toca
Ajudei? Salvei? Que tal um presentinho?
http://www.submarino.com.br/wishlistclient.asp?wlid=664176742884
"Tom Rogers" <trogers@kwikin.com> wrote in message
news:5.1.0.14.0.20020406055420.032b6bd8@crux.kwikin.com...
> Hi
> I am trying to calculate how far into a directory structure I am so that I
> can include images and include files without having to hard code them.
> I need to turn $PHP_SELF which could be /admin/emails/index.php into
../../
> which I can then use to get to any directory from root.
> like IMG src=<?echo $relative_root?>images/logo.png
> Regular expressions leave me cold but I have come up with the following
> monster which works
>
> $relative_root = preg_replace("<\/[[:alnum:]]+>","../",
> preg_replace("</[[:alnum:]]+$>","",strtok($PHP_SELF,".")));
>
> Anybody have a better solution?
> Thanks for any help.
> Tom
>