For a guide to the choosing ASP or PHP, click here
Home >> Text Files >> Count the Number of Lines in a Text File This code sample shows how to count the number of given lines in a local text file
<% ' declare variables dim fso, file1, ourFile, ourFileLines ' set our filename ourFile = "filename.txt" ' set our counter to 0 ourFileLines = 0 ' ask the system to open the file Set fso = CreateObject("Scripting.FileSystemObject") Set file1 = fso.OpenTextFile(ourFile, 1, False) ' count the lines do while not file1.AtEndOfStream ourFileLines = ourFileLines + 1; loop ' in asp, instead of looping through the ' lines, you could also read in the entire ' file, then split each line to get the count ' like this: ' ourFileLines = ubound(split(file1.ReadAll, vblf)) ' clean up our variables file1.close Set file1 = nothing Set fso = nothing ' the variable ourFileLines now holds ' the number of lines in the file ?> What is ASP?
What is PHP?