kirk112 Posted April 23, 2008 Share Posted April 23, 2008 Hi I have following variables; $v1 = 1 $v2 = 1 $v3 = 2 is there an easy way of checking to make sure that none of the variables have the same values I know how to do it using multiple if statements just wondering if there is a shorter way of doing it Thanks. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 23, 2008 Share Posted April 23, 2008 If you were to use an array, you could do this: <?php $v[1] = 1; $v[2] = 1; $v[3] = 2; if(count($v) != count(array_unique($v))){ echo 'duplicates!'; }else{ echo 'fine'; } ?> Quote Link to comment 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.