Posted in PHP onMay 05, 2017
本文实例讲述了PHP删除二维数组中相同元素及数组重复值的方法。分享给大家供大家参考,具体如下:
function assoc_title($arr, $key) { $tmp_arr = array(); foreach ($arr as $k => $v) { if (in_array($v[$key], $tmp_arr)) { unset($arr[$k]); } else { $tmp_arr[] = $v[$key]; } } return $arr; }//assoc_title end $key_title = 'stu_name'; $quchong = assoc_title($teachers, $key_title); echo "<table border=\"1\" bordercolor=\"#CCCCCC\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:collapse\" width=\"20%\">"; echo "<tr><td>id</td><td>学生名</td><td>电话</td></tr>"; $i = 1; foreach ($quchong as $key => $vale) { if ($vale['stu_name'] == "游开琳" or $vale['stu_name'] == "韩建通") { continue; } echo "<tr><td>{$i}</td><td>{$vale['stu_name']}</td><td>{$vale['tel']}</td></tr>"; $i++; } echo "</table>";
PHP删除二维数组中相同元素及数组重复值的方法示例
- Author -
phpxs声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@