Count the number of times that each number in this file appears again. how can this problem be solved?

Source: Internet
Author: User
Count the number of times that each number in this file repeats 1 to generate a 10000-line text file, one random number per row 2 count the number of repeated occurrences of each number in this file PHPcode for a more efficient method & lt ;? Counts the number of times each number appears in this file.
1. generate a 10000-line text file with one random number per line
2. count the number of times each number in this file appears again.

PHP code
  // Find a more efficient method
  "; Var_dump ($ tj); echo"
";


------ Solution --------------------
Make statistics based on your ideas. this is better,

PHP code
while($b=fgets($a)){        if(isset($list[$b]))    {        ++$list[$b];    }    else    {        $list[$b]    = 1;    }} 

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.