Jahren Posted December 3, 2008 Share Posted December 3, 2008 Hi guys quick question : is there a way to test an array has ALL different values inside like $a = array('1', '2', '3') = true $a = array('1', '1', '3') = false ? Link to comment https://forums.phpfreaks.com/topic/135436-solved-make-sure-array-values-are-different/ Share on other sites More sharing options...
corbin Posted December 3, 2008 Share Posted December 3, 2008 http://php.net/array_unique Example use: if(count($a) == count(array_unique($a)) { //unique values! } There might be a better way, as two count is kind of... bleh. Link to comment https://forums.phpfreaks.com/topic/135436-solved-make-sure-array-values-are-different/#findComment-705529 Share on other sites More sharing options...
Jahren Posted December 3, 2008 Author Share Posted December 3, 2008 hey that's ingenious thanks buddy ^^ Link to comment https://forums.phpfreaks.com/topic/135436-solved-make-sure-array-values-are-different/#findComment-705531 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.