oops, that's printf("avg for %s is %s",$year,($$high + $$low)/2);

:)

sorry

on 8/6/01 6:17 PM, mike cullerton at [EMAIL PROTECTED] wrote:

> try
> 
> for ($year=1995;$year<=2001;$year++) {
> $high = "high_" . $year;
> $low = "low_" . $year;
> printf("avg for %s is %s",$year,($high + $low)/2);
> }
> 
> 
> on 8/6/01 5:50 PM, Hugh Danaher at [EMAIL PROTECTED] wrote:
> 
>> I want to do a simple FOR statement where I average the high and low value
>> for
>> a given year.  A user will
>> input the values on a separate page and hit a submit button.  I can hard code
>> each year to do what I want, but I'd like a simpler method.  I've tried
>> variations of multiple $'s, +'s and quote marks but haven't hit on the
>> correct
>> method, and I could certainly use someone's help.
>> 
>> Thanks,
>> Hugh
>> 
>> 
>> What I want to do:
>> <?php
>> 
>> $high_1995=22;
>> $high_1996=23;
>> $high_1997=20;
>> $high_1998=18;
>> $high_1999=20;
>> $high_2000=21;
>> $high_2001=23;
>> 
>> $low_1995=22;
>> $low_1996=23;
>> $low_1997=20;
>> $low_1998=18;
>> $low_1999=20;
>> $low_2000=21;
>> $low_2001=23;
>> 
>> for ($year=1995;$year<=2001;$year++)
>> {
>> $avg_$year=($high_$year"+$low_$year)/2   //  create $avg_1995, ...
>> print "$avg_$year<br>";
>> }
>> 
>> ?>
>> 
> 
> 
> -- mike cullerton
> 
> 


 -- mike cullerton



-- 
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