Re: Extracting first eight characters of a string
| From: | Marek Kilimajer | Date: | Thu, 07 Nov 2002 15:37:11 +0000 |
| Subject: | Re: Extracting first eight characters of a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123175@lists.php.net to get a copy of this message | ||
If you want to keep non-alphanumeric characters and remove first 8 alphanumeric
characters, use
$cutstring = preg_replace("[0-9a-zA-Z]","",$originalstring,8);
or use \w if you want to remove underscore also
John Meyer wrote:
how about this: $cutstring = substr(preg_replace("\W","",$originalstring),0,8); -----Original Message----- From: Adam Voigt [mailto:adam@cryptocomm.com] Sent: Thursday, November 07, 2002 8:10 AM To: John Meyer Cc: php-general@lists.php.net Subject: Re: [PHP] Extracting first eight characters of a string Umm, this won't check, only blindly pull the first 8, but: $cutsring = substr($originalstring,0,8); Adam Voigt adam.voigt@cryptocomm.com On Thu, 2002-11-07 at 10:06, John Meyer wrote:How do I extract only the first eight characters (alpha-numeric) in astring.-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php