Re: Re: Pulling out string from a string
| From: | Justin Patrin | Date: | Tue, 04 May 2004 22:04:46 +0000 |
| Subject: | Re: Re: Pulling out string from a string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185365@lists.php.net to get a copy of this message | ||
Heh, I got ahead of myself anyway. I should have just hard-coded client.
preg_match('!/client(\d+)/!', $_SERVER['PHP_SELF'], $matches);
$xxx = $matches[1];
Ryan Schefke wrote:
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:-- paperCrane <Justin Patrin>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, Ryanpreg_match('!/([^/]+\d+)/!', $_SERVER['PHP_SELF'], $matches); $clientxxx = $matches[1];