Home >Backend Development >PHP Tutorial >PHP determines whether the two-dimensional array retrieved from the database has duplicate values
In project development, we sometimes need to know whether the data we find is duplicated. Generally, the data we find is two-dimensional data, so as long as one field is unique, we can judge. Simple accumulation and reduced duplication of work.
Go directly to the code
public function isRepeat(){ // 微擎查数据库方法 $list = pdo_getall('ewei_shop_member'); $list = array_column($list,'openid'); if (count($list) != count(array_unique($list))) { echo '该数组有重复值'; }else{ echo '该数组没有重复值'; } }
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of PHP determines whether the two-dimensional array retrieved from the database has duplicate values. For more information, please follow other related articles on the PHP Chinese website!