I'm trying to take a text file and count the number of lines that match
a regexp.  I've got it working using the following code:

$data = file("myfile.txt");
$total = 0;
foreach($data as $i) {
        if (ereg("^1,",$i)) {
                $total = $total + 1;
        }
}

but I'm still learning PHP and am wondering if there's an easier/better
way to do this?

Thanks.

--kurt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to