Re: Full Range ?



On Apr 30, 10:30 am, "Janwillem Borleffs" <j...@xxxxxxxxxxxxx> wrote:
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

Hi,

Thanks for that - I thought I'd tried the array_merge but obviously
wasn't doing something properly.

Thanks

A
.



Relevant Pages

  • Re: matching special characters
    ... It is certainly possible to do this kind of matching, ... course the characters you are interested in must be in Unicode. ... named ranges: ... expressions of this type if they cross Unicode ranges. ...
    (comp.editors)
  • Re: Generic algorithms for looseless compression
    ... For 2 Characters we have the ranges: ... In that decimal system we have gaps between the ranges, ... because we choosed the ASCII System. ...
    (comp.compression)
  • Re: Converting between positional numeral systems
    ... Proper ranges of to be represented characters had to be chosen from the ... Excluding ranges lead to the circumstance that the decimal numbers ... This approach doesn't help for bigger bases than 36. ...
    (comp.lang.logo)
  • Re: Generic algorithms for looseless compression
    ... For 2 Characters we have the ranges: ... In that decimal system we have gaps between the ranges, ...
    (comp.compression)
  • Re: Very Slow character counting in Word 2003
    ... Word has to count through all the characters from the ... underline ...) ... Word already "knows" the ranges that are underlined. ... > Dim UnderlineState As Boolean ...
    (microsoft.public.word.vba.general)