Home > Article > Backend Development > PHP realizes the method of deleting the same elements and duplicate values in the array in the two-dimensional array
This article mainly introduces the method of PHP to delete the same elements in the two-dimensional array and the duplicate values of the array, involving PHP's array traversal, judgment, comparison and other related operation skills. Friends in need can refer to it
The example in this article describes the method of PHP to delete the same elements and duplicate values in the array in a two-dimensional array. Share it with everyone for your reference, the details are as follows:
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>";
## Related recommendations:
How to use the explode() function in PHP to cut a string into an array
PHP implements the method of calculating the frequency of words in a file or array
phpBasic learning: PHP Array and data structure
##
The above is the detailed content of PHP realizes the method of deleting the same elements and duplicate values in the array in the two-dimensional array. For more information, please follow other related articles on the PHP Chinese website!