MemphiS Posted August 2, 2008 Share Posted August 2, 2008 Problem is i have users select 8 numbers and then submit the data and i need to check that each of the 8 numbers are different.. I know its a simple problem, but im afraid i just cant think tonight Quote Link to comment https://forums.phpfreaks.com/topic/117802-checking-numbers-in-an-array/ Share on other sites More sharing options...
Andy-H Posted August 2, 2008 Share Posted August 2, 2008 <?php if ($_POST['radio']){ $c = 0; $a = array(); foreach(intval($_POST['radio']) as $value) { if ($c < { if (!in_array($value, $a)){ $a[] = $value; $c++; }}}} ?> Duno if that will work but I thaught I'd have a crack Quote Link to comment https://forums.phpfreaks.com/topic/117802-checking-numbers-in-an-array/#findComment-605916 Share on other sites More sharing options...
genericnumber1 Posted August 2, 2008 Share Posted August 2, 2008 <?php if(count($numArray) != count(array_unique($numArray))) { echo 'error! dupe values in array!'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/117802-checking-numbers-in-an-array/#findComment-605921 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.