PHP array A field data duplication problem

Source: Internet
Author: User
1. Define an empty array as a container,
$send _box_array = Array (

' Total ' =>0,//number of non- repeating data (total box count)

' list ' =>array ()//array with no duplicate data (box number name)

);

2. Judging duplicate data in a cyclic search result data

The first kind: isset judgment

foreach ($result as $good _list) {
Get the total send box num
if (!isset ($send _box_array [' list '] [$good _list[' Send_box_no '])) {
$send _box_array [' Total ']++;
$send _box_array [' list '] [$good _list[' send_box_no ']] = ';
}
。。。
}

Self:: $wms _data[$num] [' user_def2 '] = $send_box_array [' Total '];

Second type: In_array ()

foreach ($result as $good _list) {
Get the total send box num
if (! In_array($good _list[' send_box_no '), $send _box_array [' list ']) {
$send _box_array [' Total ']++;
$send _box_array [' list '] [] = $good _list[' send_box_no '];
}
。。。
}

Self:: $wms _data[$num] [' user_def2 '] = $send_box_array [' Total '];


The above describes the PHP array of a field data duplication problem, including the content of data duplication, I hope the PHP tutorial interested in a friend helpful.

  • 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.