PDA

View Full Version : in_array problem


tsclan
09-13-2004, 03:20 AM
OK a small but annoying thing here
I have made this log in system where you can only see the page if $logged_in == '1' and only if "News" is in the array
this is what I have so far

<?php
if ( in_array("News", $access ) | $logged_in == '1' ) {
//page stuff here
}else{
//error here
}
?>

I am aware of the case sensitive "News" and please persume that the $access array does not have the word "News" in it.
the strange thing is that it doesnt show the page ( as in it works ) when i just have this

<?php
if ( in_array("News", $access ) ) {
//page stuff here
}else{
//error here
}
?>

So basically I wont it so that you can view the page if you are logged in ($logged_in == '1' ) or News is in the array
thanks and sorry about the comprehension as I am tired :D

Kurashu
09-13-2004, 04:07 AM
<?php
if ( in_array("News", $access ) || $logged_in == '1' ) {
//page stuff here
}else{
//error here
}
?>

You need two |'s, or an OR command.