Jump to content

show line number


thibo1025

Recommended Posts

how with a php tag show the number of coding lines that are in an other sheet?It is rather important for me to know this. If you could help me out for this it would be nice thank you

Link to comment
Share on other sites

For what sort of program do you want to use this information?If you mean the written lines in one file, they can be count from within an editor, the filesize can be looked up by FTP instructions, but why the lines count?Do you have some sory of simple database built, called a flat file, from which you like to know how many entries it consists of? Or something else? :)There is a way of counting the lines by actual reasonable advanced coding, but that may not be what you want - after all there are better ways to store your information else than in a flat file :)

Link to comment
Share on other sites

Actually what I want is simpler than that (well I think). What I want to count is the number of lines in the source of the file for example

<html><head><title></tilte></head><body><p>hello</p></body></html>

contains 9 or 10 lines and that is the number I want to be able to show.

Link to comment
Share on other sites

Right - so you count the number of line breaks, and add one.This file:

line1\nline2\nline3

Has 2 line breaks, and there are three lines. Count the number of line breaks. You can explode the string on a newline and count the number of array elements, use substr_count to determine how many there are, or just walk through the string and count up the newlines. However you want to accomplish it, that's what you do, I'm telling you.

Link to comment
Share on other sites

ok this seams perfect only can I do instead

<?php$read = "yourfilename.htm";$count = count($read);$lines = $count - "1";echo "There are $lines lines in $read.";?>

because it is counting one line to much... so can you tell me if this is the way to fix it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...