|
-
Apr 15th, 2002, 09:14 PM
#1
Thread Starter
Member
Number of lines in a file?
Other than iterating through each line and incrementing a counter (seems too resource-intensive), how can I find out how many lines are in a certain file?
-
Apr 15th, 2002, 09:42 PM
#2
Stuck in the 80s
Code:
$file = file('yourfile');
$x = count($file);
echo $x . ' lines in the file.'
Or something to that extent.
-
Apr 15th, 2002, 09:45 PM
#3
Thread Starter
Member
Cool 
BTW...
PHP Code:
echo $x . ' lines in the file.'
...can be replaced with...
PHP Code:
echo "$x lines in the file."
-
Apr 15th, 2002, 09:46 PM
#4
Stuck in the 80s
ah, nice to know.
Code:
//I should use the php tags, huh?
$file = file('yourfile');
$x = count($file);
echo $x . ' lines in the file.'
could probably be replace with:
Code:
echo count(file('yourfile')) . ' lines in the file.'
Althought I haven't tried it
-
Apr 15th, 2002, 09:49 PM
#5
Thread Starter
Member
Probably could, very C++/Java-like if it works
-
Apr 15th, 2002, 09:52 PM
#6
Stuck in the 80s
FYI, just tried it. Works like a charm.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|