RE: [PHP] Re: Pulling out string from a string
| From: | Ryan Schefke | Date: | Tue, 04 May 2004 21:47:43 +0000 |
| Subject: | RE: [PHP] Re: Pulling out string from a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185361@lists.php.net to get a copy of this message | ||
Justin,
Very nice preg_match statement. I realized I need to make a minor tweek to
what I needed. I need to get the number after the "client" string in
/tgwedding/users/client1/sites/testgrabid.php
...so, in the string above I need to pull out the number "1".
Any help?
-----Original Message-----
From: Justin Patrin [mailto:papercrane@reversefold.com]
Sent: Tuesday, May 04, 2004 5:43 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Pulling out string from a string
Ryan Schefke wrote:
> Can anyone help me with the code to pull out "clientxxx" from the below
> string:
>
> /tgwedding/users/client1/sites/testgrabid.php
>
>
>
> I use $PHP_SELF to get the directory structure of the page and store that
> string as a variable. Then, I want to pull out the string "clientxx",
where
> "xx" can be any given number.
>
> Thanks,
> Ryan
>
>
>
>
preg_match('!/([^/]+\d+)/!', $_SERVER['PHP_SELF'], $matches);
$clientxxx = $matches[1];
--
paperCrane <Justin Patrin>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php