Re: Full Range ?
- From: "Twayne" <nobody@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 30 Apr 2008 16:30:57 GMT
UKuser wrote:
Just to save a bit of code - is there an easier way without typing
out all the letters/numbers to do this?
foreach (range("A","Z") as $v){$variables[] = $v;}
foreach (range("a","z") as $v){$variables[] = $v;}
foreach (range("1","9") as $v){$variables[] = $v;}
Effectively making one array with all letters & numbers
Highly inefficient, but no typing of characters:
for ($i = 49; $i < 122; $i++) {
if ($i == 95) continue; // skip underscore
if (preg_match('/\w/', chr($i))) $variables[] = chr($i);
}
It would be better to array_merge the three ranges:
$variables = array_merge(range('A','Z'),range('a','z'),range(1,9));
Keeping the original format also allows you to add/delete included
characters in a more convenient way.
HTH;
JW
Won't a VAR_FILTER that'll do that? I'm using one for form validation.
Twayne
.
- References:
- Full Range ?
- From: UKuser
- Re: Full Range ?
- From: Janwillem Borleffs
- Full Range ?
- Prev by Date: Re: include, relative path
- Next by Date: Re: include, relative path
- Previous by thread: Re: Full Range ?
- Next by thread: include, relative path
- Index(es):
Relevant Pages
|