seany123 Posted November 28, 2008 Share Posted November 28, 2008 okay so basically what i need to do is have a if statement, but the twist is that the value of House_id could be 0 or anything from 1 to 16... this is basically what im wanting but obviously this code wont work. if ($player->house_id == 2 || $player->house_id == 3 || $player->house_id == 4) { } But also it would go up to 16 instead of 4. can anyone help me do this? (for example: it cant use >9. because it would miss out 7,6,5,4,3,2,1. anyone understand what i mean? Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/ Share on other sites More sharing options...
ratcateme Posted November 28, 2008 Share Posted November 28, 2008 what about if($player->house_id != 0) //will return true for ever number but 0 or if($player->house_id > 0) //will return true for every positive number or if($player->house_id > 0 && $player->house_id < 17) //will return true for 1-16 Scott. Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701312 Share on other sites More sharing options...
seany123 Posted November 28, 2008 Author Share Posted November 28, 2008 if($player->house_id > 0 && $player->house_id < 17) //will return true for 1-16 but what if i didnt want for example 12 to return true? Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701318 Share on other sites More sharing options...
ratcateme Posted November 28, 2008 Share Posted November 28, 2008 if($player->house_id > 0 && $player->house_id < 17 && $player->house_id != 12) //number is between 1-16 and not 12 what about if($player->house_id != 0 $player->house_id != 12) //so it isn't 0 and isn't 12 but could be 17 Scott. Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701327 Share on other sites More sharing options...
.josh Posted November 28, 2008 Share Posted November 28, 2008 if($player->house_id > 0 && $player->house_id < 17) //will return true for 1-16 but what if i didnt want for example 12 to return true? Well your OP said anything from 0-16, so which is it? 0-16 or 0-16 except some random number like 12? Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701331 Share on other sites More sharing options...
seany123 Posted November 28, 2008 Author Share Posted November 28, 2008 if($player->house_id > 0 && $player->house_id < 17) //will return true for 1-16 but what if i didnt want for example 12 to return true? Well your OP said anything from 0-16, so which is it? 0-16 or 0-16 except some random number like 12? 0-16 except one random number. I tried this : if($player->house_id != 0 && $player->house_id != 1) { header("location: estateagent.php"); } but got a unexpected T_VARIABLE error Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701335 Share on other sites More sharing options...
ratcateme Posted November 28, 2008 Share Posted November 28, 2008 check the line above it has it got a ; the code you posted has no errors Scott. Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701343 Share on other sites More sharing options...
.josh Posted November 28, 2008 Share Posted November 28, 2008 <?php $min = 0; $max = 16; $randomNum = 12; if ((in_array($player->house_id, range($min, $max))) && ($player->house_id != $randomNum)) { echo "true"; } ?> Link to comment https://forums.phpfreaks.com/topic/134686-if-statement-help/#findComment-701344 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.