Similarity of two-dimensional array judgment values

Source: Internet
Author: User
The two-dimensional array has the same judging value
$array = Array (' PID ' =>1, ' name ' =>a), array (' PID ' =>2, ' name ' =>b), array (' PID ' =>3, ' name ' =>c), Array (' PID ' =>1, ' name ' =>a), array (' PID ' =>4, ' name ' =>d));
A two-dimensional array like this, how to determine the PID and name are equal values (as in the example (' PID ' =>1, ' name ' =>a) value)
Some words, you quit.

------Solution--------------------
PHP Code
$array = Array (' PID ' =>1, ' name ' = ' a '), array (' PID ' =>2, ' name ' = ' B '), Array (' PID ' =>3, ' NA Me ' = ' C '), Array (' PID ' =>1, ' name ' = ' a ')), $tmp =array (), foreach ($array as $k + $v) {if (! $tem [$v [PID]. ' _ '. $v [name]]) {$tem [$v [PID]. '              _ '. $v [name]]= $v;        Print_r ($v);                }else{exit; }        }
------Solution--------------------
PHP code
 $array = Array (' pid ' = = 1, ' name ' = ' a ' ), array (' pid ' = = 2, ' name ' = ' B '), Array (' pid ' = = 3, ' name ' = ' C '), Array (' pid ' = 4, ' name ' =& Gt  ' d '), Array (' pid ' = = 5, ' name ' = = ' E '), array (' pid ' = = 1, ' name ' = ' a '), array (' pid ' = 4, ' name ' = ' d '), $idList = Array (), foreach ($array as $key = = $value) {$idList [] = Implode (', ', $value);} $idList 2 = Array_diff_assoc ($idList, Array_unique ($idList)), foreach ($idList 2 as $key + = $value) {$akey = Array_sea    RCH ($value, $idList);    echo ' repeating array: '; Print_r ($array [$akey]);} 
  • Related Article

    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.