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