cooldude832 Posted July 26, 2007 Share Posted July 26, 2007 I'm trying to come up with a list of banned numbers so to say that looks like this below <?php $badnums = array(1,2,4,5,7,8,23); $num = $_SESSION['num']; if($num != $badnums){ //Good } else{ //bad } ?> I know you can't do that so what I thought of was something else like <?php $badnums = array(1,2,4,5,7,8,23); $num = $_SESSION['num']; $badnums = implode("&&".$num."!= ".,$badnums); if($num != $badnums){ //Good } else{ //bad } ?> Does that make sense? I think it would work but is there an easier way? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 not clear? can you explain a bit and base on that code using in_array i guess is better Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 26, 2007 Author Share Posted July 26, 2007 that would about do it basically what i'm doing except i'm manually creating the additional comparison strings Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 26, 2007 Author Share Posted July 26, 2007 it be <?php $badnums = array(1,2,4,5,7,8,23); $num = $_SESSION['num']; $badnums = implode("&&".$num."!= ".,$badnums); if(!in_array($num,$badnums)){ //Good } else{ //bad } ?> Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 26, 2007 Share Posted July 26, 2007 <?php $banned= array(1, 3, 5, 7); $num = $_SESSION['num']; if (in_array($num, $banned)) { echo "You are Bant."; } else { ?> Your HTML here. <?php } ?> ?? Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 26, 2007 Share Posted July 26, 2007 ya thats better that using explode or looping to reach the condition you need Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.