Re: Full Range ?



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


.



Relevant Pages

  • Re: Full Range ?
    ... out all the letters/numbers to do this? ... Highly inefficient, but no typing of characters: ...
    (alt.php)
  • Re: [Xnews] Kill by M-ID
    ... seems to be exactly 8 letters/numbers before the @ sign. ... I looked through the PCRE file and then tried various rules such ... More than being just any 8 characters, it appears to be 8 Hexadecimal ... Use of the colon rather than equals after Message-ID will ...
    (news.software.readers)
  • Re: On topic - great software for an MT
    ... professional expander, and, believe me, you really, really, really want ... to simply typing a few characters and hitting a double space or F10. ... been completely blown away by the results, a single script that lets ...
    (sci.med.transcription)
  • Re: Great SWT Program
    ... to whether it's faster to type 2N characters than N characters ... assuming a typing speed of x characters per second, ... The gap will be narrower for faster typists. ... average out to 2N characters taking twice as long to type. ...
    (comp.lang.java.programmer)
  • Re: The Impotance Of Being Earnest
    ... are available simply by holding the ALT key while typing a code ... characters with the code numbers? ...
    (rec.woodworking)