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: [EMAIL PROTECTED]
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
[EMAIL PROTECTED]

On Thu, 2002-11-07 at 10:06, John Meyer wrote:

How do I extract only the first eight characters (alpha-numeric) in a

string.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to