Re: Adding up values

From: Date: Fri, 10 May 2002 06:52:37 +0000
Subject: Re: Adding up values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-96914@lists.php.net to get a copy of this message
On Friday 10 May 2002 14:27, Miguel Cruz wrote: > There's really not much to it. The intval of '-' is 0, so it doesn't cause > any problems. > > $numbers = file('path/logfile.txt'); > $total = 0; > foreach ($numbers as $num) $total += intval($num); Or use array_sum(): $numbers = file('path/logfile.txt'); $total = array_sum($numbers); -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* "What if" is a trademark of Hewlett Packard, so stop using it in your sentences without permission, or risk being sued. */

« previous php.general (#96914) next »