PHP method for obtaining the number of file lines ,. The PHP method for getting the number of file lines. this example describes how PHP can get the number of file lines. Share it with you for your reference. The specific analysis is as follows: two implementation methods are provided, although the second PHP method obtains the number of file lines,
This example describes how to obtain the number of objects in PHP. Share it with you for your reference. The specific analysis is as follows:
Two implementation methods are provided. although the second method is easy to understand, the first method is the best.
First:
<? Php $ file_path = 'xxx.txt '; // file path $ line = 0; // Number of initialization rows // open the file $ fp = fopen ($ file_path, 'r ') or die ("open file failure! "); If ($ fp) {// get the content of a row of the file. note: php5 is required to support this function. while (stream_get_line ($ fp, 8192, "\ n") {$ line ++;} fclose ($ fp); // close the file} // Number of output rows; echo $ line;?>
Second:
<? Php $ line = count (file ('filename'); echo $ line;?>
The second method is inefficient because you want to save the file content.
I hope this article will help you with php programming.
Example: This article describes how to obtain the number of objects in PHP. Share it with you for your reference. The specific analysis is as follows: two implementation methods are provided, although the second...