Re: Looping Addition

From: Date: Thu, 05 Dec 2002 00:44:19 +0000
Subject: Re: Looping Addition
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127072@lists.php.net to get a copy of this message
On Wed, 4 Dec 2002, Stephen wrote: > I already have that. $_POST['vars'] is a number and I already check that you > on a page before. All I need to know is how to keep adding numbers until > there are no more to add... If you mean that $_POST['vars'] is an array of numbers: $total = 0; foreach( $_POST['vars'] as $number ){ $total += $number; } If you mean that all vars in the POST data are numbers you want to add: $total = 0; foreach( $_POST as $number ){ $total += $number; } g.luck, ~Chris

« previous php.general (#127072) next »