Re: [PHP] Using File to count number of lines
you sure each is on its own line (\n) ? if you're only getting a value of 1 it is likely putting everything on a single array key.. Tom Chubb wrote: I'm having a problem with the following code: ?php $file = http://www.mysite.co.uk/mailing_list_database.list;; $lines = count(file($file)); echo $lines ; ? I'm trying to show the number of subscribers to my visitors from a text file, but it returns a value of 1 when it should be 5000. I think it's to do with recognising the line break but I don't know how to make it work!?! (I've looked on php.net for the file, fopen count functions and can't find anything, although fopen mentions using the -t mode. Any ideas? Thanks, Tom -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using File to count number of lines
When I open the list in notepad everything is on one line with a square box character. When I open it in wordpad, it's one email address on each line. On 04/08/05, Sebastian [EMAIL PROTECTED] wrote: you sure each is on its own line (\n) ? if you're only getting a value of 1 it is likely putting everything on a single array key.. Tom Chubb wrote: I'm having a problem with the following code: ?php $file = http://www.mysite.co.uk/mailing_list_database.list;; $lines = count(file($file)); echo $lines ; ? I'm trying to show the number of subscribers to my visitors from a text file, but it returns a value of 1 when it should be 5000. I think it's to do with recognising the line break but I don't know how to make it work!?! (I've looked on php.net for the file, fopen count functions and can't find anything, although fopen mentions using the -t mode. Any ideas? Thanks, Tom -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- Tom Chubb [EMAIL PROTECTED] 07915 053312 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Using File to count number of lines
[snip] When I open the list in notepad everything is on one line with a square box character. When I open it in wordpad, it's one email address on each line. [/snip] Sounds like that there are not any newline characters in the file. You could do something like this... $theFile = fopen(http://www.mysite.co.uk/mailing_list_database.list;, r); while(!feof($theFile)){ $theLine = fgets($theFile, 4096); $theCount++; } fclose($theFile); echo $theCount; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using File to count number of lines
do this: $file = 'http://www.mysite.co.uk/mailing_list_database.list'; echo 'pre'; print_r($file); echo '/pre'; im pretty sure you'll only see 1 key.. if each has its own line, you would see something like: Array ( [0] = foo [1] = foo [2] = foo [3] = foo ) etc... Tom Chubb wrote: When I open the list in notepad everything is on one line with a square box character. When I open it in wordpad, it's one email address on each line. On 04/08/05, Sebastian [EMAIL PROTECTED] wrote: you sure each is on its own line (\n) ? if you're only getting a value of 1 it is likely putting everything on a single array key.. Tom Chubb wrote: I'm having a problem with the following code: ?php $file = http://www.mysite.co.uk/mailing_list_database.list;; $lines = count(file($file)); echo $lines ; ? I'm trying to show the number of subscribers to my visitors from a text file, but it returns a value of 1 when it should be 5000. I think it's to do with recognising the line break but I don't know how to make it work!?! (I've looked on php.net for the file, fopen count functions and can't find anything, although fopen mentions using the -t mode. Any ideas? Thanks, Tom -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using File to count number of lines
sorry, i forgot to put file(); Sebastian wrote: do this: $file = 'http://www.mysite.co.uk/mailing_list_database.list'; echo 'pre'; print_r($file); echo '/pre'; im pretty sure you'll only see 1 key.. if each has its own line, you would see something like: Array ( [0] = foo [1] = foo [2] = foo [3] = foo ) etc... Tom Chubb wrote: When I open the list in notepad everything is on one line with a square box character. When I open it in wordpad, it's one email address on each line. On 04/08/05, Sebastian [EMAIL PROTECTED] wrote: you sure each is on its own line (\n) ? if you're only getting a value of 1 it is likely putting everything on a single array key.. Tom Chubb wrote: I'm having a problem with the following code: ?php $file = http://www.mysite.co.uk/mailing_list_database.list;; $lines = count(file($file)); echo $lines ; ? I'm trying to show the number of subscribers to my visitors from a text file, but it returns a value of 1 when it should be 5000. I think it's to do with recognising the line break but I don't know how to make it work!?! (I've looked on php.net for the file, fopen count functions and can't find anything, although fopen mentions using the -t mode. Any ideas? Thanks, Tom -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php