PHP Log parsing small script to analyze the number of statistics (from large to small) that contain the same string per line

Source: Internet
Author: User
Tags explode

<?phpheader ("content-type:text/html; Charset=utf-8 "), $file = fopen (" Sqlstr.txt "," R "), $sql _arr=array (), $i =0;//all lines in the output text until the end of the file. while (! feof ($file)) {$sql _arr[$i]= fgets ($file); the//fgets () function reads a row from the file pointer $i + +; Fclose ($file); $sql _arr=array_filter ($sql _arr);//Here is a variable $bianliang1 to identify the first array $bianliang1= ' AAA '; foreach ($sql _arr as $k = = & $v) {$newarr [$k] = explode ($bianliang 1, $v);} The variable $bianliang1 is used here to identify the second array $bianliang2= ' BBB '; foreach ($newarr as $k = = & $v) {if (!empty ($v [1]) {$newtwo [$k] = Explode ($bianliang 2, $v [1]);}} foreach ($newtwo as $k = & $v) {$aaa [] = $v [0];} $i = count ($aaa); $ok = Array_count_values ($AAA); Arsort ($ok); Echo ' <pre> '; Echo ' total '. $i. " "Echo ' <br> ';p rint_r ($ok);? >


PHP Log Analysis script to parse the number of statistics (from large to small) that contain the same string per line

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.