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 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 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!'; } ?> 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
Archived
This topic is now archived and is closed to further replies.