Page 1 of 1

Two part question about ranges, arrays, and in_array

Posted: Sat Jul 01, 2006 2:49 pm
by Bigun
Part 1-

I'm aware of making ranges:

Code: Select all

$alphabet=(range('a', 'z')
And of the in_array function..

Can you put more than one array/variable into the in_array function and it still work?

Code: Select all

$lowercase=(range('a','z');
$uppercase=(range('A','Z');

//Put both of the above variables into an in_array function

Part 2-

In a PHP/MySQL/HTML environment, what characters are not safe to use and can compromise security in an environment?

Posted: Sat Jul 01, 2006 4:17 pm
by John Cartwright
do you mean

Code: Select all

if (in_array('letter', $lowercase) && in_array('letter', $uppercase)) {  }
?

Posted: Sat Jul 01, 2006 4:52 pm
by Bigun
Kinda:

Code: Select all

if (!in_array('letter', $lowercase) && !in_array('letter', $uppercase)) {  
     //reject string, some characters not allowed
}
But without the ugly '&&' in the if statement....

Posted: Sat Jul 01, 2006 5:55 pm
by Robert Plank

Code: Select all

if (in_array('letter', array_merge($lowercase, $uppercase))) {
   // reject
}

Posted: Sat Jul 01, 2006 5:57 pm
by Bigun
Guh.... love it