vikela Posted September 28, 2009 Share Posted September 28, 2009 here is the challenge i am facing.i have a field that contains integers ranging from 1 to 10.how can i pull and display in a select menu numbers that are not yet in the field.i was thinking of creating an array of numbers that range (1-10) then compare with the numbers within the field but i am somehow failing to have the comparison work.. > :'( $arr=array(1,2,3,4,5,6,7); foreach($find as $test ){ if(in_array($test['rank'],$arr)){ echo "NUMBER ... is present"; } else{ echo "TESTTTTTTTTT"; } } whats my challenge?i would like it to show me the numbers that are not in the field 'rank' and this actually will be in a select menu so that a user select any of the non used number. Link to comment https://forums.phpfreaks.com/topic/175792-retrieve-used-numbers/ Share on other sites More sharing options...
kickstart Posted September 28, 2009 Share Posted September 28, 2009 Hi Set up an array with the values 1 to 10 and then use the array_diff function. All the best Keith Link to comment https://forums.phpfreaks.com/topic/175792-retrieve-used-numbers/#findComment-926434 Share on other sites More sharing options...
Mark Baker Posted September 28, 2009 Share Posted September 28, 2009 You could always look at the previous responses to this request before asking again. Link to comment https://forums.phpfreaks.com/topic/175792-retrieve-used-numbers/#findComment-926435 Share on other sites More sharing options...
Daniel0 Posted September 28, 2009 Share Posted September 28, 2009 You could always look at the previous responses to this request before asking again. Actually, this topic is the first one he made. Either way, this one gets locked because the other one contains more elaborate answers. Link to comment https://forums.phpfreaks.com/topic/175792-retrieve-used-numbers/#findComment-926496 Share on other sites More sharing options...
Recommended Posts