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 ? 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. 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 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 Link to comment https://forums.phpfreaks.com/topic/259315-how-do-i/#findComment-1329302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.