Two part question about ranges, arrays, and in_array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Two part question about ranges, arrays, and in_array

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

do you mean

Code: Select all

if (in_array('letter', $lowercase) && in_array('letter', $uppercase)) {  }
?
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post 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....
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

Code: Select all

if (in_array('letter', array_merge($lowercase, $uppercase))) {
   // reject
}
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

Guh.... love it
Post Reply