PHP: example of how to delete identical elements and repeated values in two-dimensional arrays. Example of two-dimensional arrays

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.