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