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. Link to comment https://forums.phpfreaks.com/topic/102518-validation-three-values/ 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/102518-validation-three-values/#findComment-524881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.