PHP: example of how to delete identical elements and repeated values in two-dimensional arrays. Example of two-dimensional arrays
This article describes how to delete identical elements and repeated values in two-dimensional arrays by using PHP. We will share this with you 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> Student name </td> <td> phone number </td> </tr> "; $ I = 1; foreach ($ quchong as $ key => $ vale) {if ($ vale ['stu _ name'] = "youkailin" or $ vale ['stu _ name'] = "Han jiantong") {continue ;} echo "<tr> <td >{$ I} </td> <td >{$ vale ['stu _ name']} </td> <td >{$ vale ['tel ']} </td> </tr> "; $ I ++;} echo "</table> ";
PS: Here are several repeated tools for your reference:
Online deduplication tools:
Http://tools.jb51.net/code/quchong
Online text deduplication tool:
Http://tools.jb51.net/aideddesign/txt_quchong