?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help

?
?Re: T_Double_Arrow (Parse Error)
Author:??(---.cpe.net.cable.roger)
Date:???04-28-04 16:17

sorry, my bad...its your foreach statement that is screwy

foreach($cities as $destination=>$distance){
if ($miles < 500) {
print "Destination $Destination Distance = $miles
";
}elseif (($miles>500) && ($miles < 1000)){
print "Destination $Destination Distance = $miles
";
}elseif (($miles>1000) && ($miles < 1500)){
print "Destination $Destination Distance = $miles
";
}

}//close for each loop

you only need one foreach loop for the array and a bunch of if/elseif statements to print out what you want to ....note that from the code your if/elseif don't make much sense...the <> symbol is not equal and none of the value are equal to any of those statements...not sure what the goal of the exercise is, but either less than or greater than may be more useful to you...

?Topics Author? Date
?T_Double_Arrow (Parse Error)??new
Rachel 04-27-04 12:55?
?Re: T_Double_Arrow (Parse Error)??new
bastien 04-28-04 07:18?
?Re: T_Double_Arrow (Parse Error)??new
bastien 04-28-04 16:17?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > sorry, my bad...its your foreach statement that is screwy > > foreach($cities as $destination=>$distance){ > if ($miles < 500) { > print "Destination $Destination Distance = $miles
"; > }elseif (($miles>500) && ($miles < 1000)){ > print "Destination $Destination Distance = $miles
"; > }elseif (($miles>1000) && ($miles < 1500)){ > print "Destination $Destination Distance = $miles
"; > } > > }//close for each loop > > you only need one foreach loop for the array and a bunch of > if/elseif statements to print out what you want to ....note > that from the code your if/elseif don't make much sense...the > <> symbol is not equal and none of the value are equal to any > of those statements...not sure what the goal of the exercise > is, but either less than or greater than may be more useful > to you... ">??

Provided By
Phorum