Simple email PHP counter script.?

yvetteRPI

New member
I have a text file with a lot of emailaddresses, is there any way I can count them with a simple PHP script that says "you have xxx emailaddresses", I need it so I can use it for my newsletter system.
 
Assuming your e-mail addresses are in file.txt:

<?php
$fp = fopen('file.txt', 'r');
if(false !== $fp) {
$i = 0;
while(!feof($fp)) {
$data = fgets($fp, 4096);
$i++;
}
echo "You have $i e-mail addresses";
}
else {
echo "can't open text file";
}
fclose($fp);
?>
 
if each email address is one a new line

<?php

$file = "somefile.txt";



$lines = count(file($file));



echo "There are $lines lines in $file";

?>
 
if each email address is one a new line

<?php

$file = "somefile.txt";



$lines = count(file($file));



echo "There are $lines lines in $file";

?>
 
Back
Top