How to use PHP arrays to sort millions of data _php tutorial

Source: Internet
Author: User
How to use PHP arrays to rank millions of data

In peacetime work, often received to the site members of the station letter, mobile phone text messages, e-mail for mass information notification, the user list is generally provided by other colleagues, which will inevitably have to repeat, in order to avoid repeated sending, so I have to send information before sending them to the user list to arrange for weight, Below I am using the UID list to say how I use the PHP array for the weight.

If you get a list of UID, the number is more than million lines, the format is as follows:

10001000

10001001

10001002

................

10001000

................

10001111

In fact, using the characteristics of the PHP array, very good for the row weight, we first look at the definition of PHP array: The array in PHP is actually an ordered map. A map is a type that associates values to the keys. This type is optimized in many ways, so it can be used as a real array, or as a list (vector), a hash (an implementation of a mapping), a dictionary, a collection, a stack, a queue, and more possibilities. The value of an array element can also be another array. Tree structures and multidimensional arrays are also allowed.

In an array of PHP, the keys are also known as indexes, which are unique, and we can use this feature for the weight of the sample code as follows:

     
     $v) {    $content. = $k. " n ";} $fp = fopen (' Result.txt ', ' W '); fwrite ($fp, $content); fclose ($FP);? >
More than 20 lines of code, you can be more than millions of data for the row weight, efficiency is good, very practical. Mobile phone number, email, you can also use this method for weight.

Also, this method can also be used for two files for the work of the weight, if you have two UID list file, the format and the above UID list, the sample program is as follows:

    
      

When you think about it, it's easy to see that using this feature of the array can also solve more problems in our work.

http://www.bkjia.com/PHPjc/371622.html www.bkjia.com true http://www.bkjia.com/PHPjc/371622.html techarticle How to use PHP array to weight millions of data in peacetime work, often received to the site members of the station letter, mobile phone text messages, e-mail for mass information notification, user list ...

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