Monkuar Posted March 20, 2012 Share Posted March 20, 2012 use the in_array to check a loop ? like $os = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $os)) { echo "Got Irix"; } if (in_array("mac", $os)) { echo "Got mac"; } Now what if $os becomes for ($i = 1; $i <= 10; $i++) { $os .= $i } now if I use: if (in_array($FORMPOST[couldbeanything], $os)) { echo "Correct entry"; exit; } if (!in_array($FORMPOST[couldbeanything], $os)) { echo " bad entry "; exit; } would it work only through 1-10 numbers? :shrug: :shrug: and echo out "bady" entry if it's NOT 1-10 ? Quote Link to comment https://forums.phpfreaks.com/topic/259315-how-do-i/ Share on other sites More sharing options...
ChemicalBliss Posted March 20, 2012 Share Posted March 20, 2012 change $os .= $i; to $os[] = $i; and you got yourself a winner. Quote Link to comment https://forums.phpfreaks.com/topic/259315-how-do-i/#findComment-1329299 Share on other sites More sharing options...
Monkuar Posted March 20, 2012 Author Share Posted March 20, 2012 dam so easy to prevent sql injection lol ty Quote Link to comment https://forums.phpfreaks.com/topic/259315-how-do-i/#findComment-1329301 Share on other sites More sharing options...
seanlim Posted March 20, 2012 Share Posted March 20, 2012 You might want to look at the range() function too http://www.php.net/manual/en/function.range.php Quote Link to comment https://forums.phpfreaks.com/topic/259315-how-do-i/#findComment-1329302 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.