ardyandkari Posted August 24, 2008 Share Posted August 24, 2008 hello...i am trying to use the foreach() function to no avail. here is my code: foreach (($arrayfrom as $key1 => $arrfrom) && ($arrayto as $key2 => $arrto)) { if (($count >=($arrfrom)) && ($count <= ($arrto))) {echo "<td bgcolor='#000000'>".$dayArray["mday"]." </td>\n"; $start += ADAY; } i get the following error: Parse error: syntax error, unexpected T_AS in C:\wamp\www\resort\literes\test.php on line 132 what am i doing wrong? i have $arrayfrom and $arrayto defined above as an array()...i tried taking out && ($arrayto as $key2 => $arrto) and it still comes up with the same error...kinda confused :-\ ....... Link to comment https://forums.phpfreaks.com/topic/121141-problem-with-foreach-function/ Share on other sites More sharing options...
MasterACE14 Posted August 24, 2008 Share Posted August 24, 2008 I'm not sure whether you can do 2 foreach's within the 1 function. And make the as uppercase AS. Link to comment https://forums.phpfreaks.com/topic/121141-problem-with-foreach-function/#findComment-624516 Share on other sites More sharing options...
PFMaBiSmAd Posted August 24, 2008 Share Posted August 24, 2008 The definition of foreach: There are two syntaxes; the second is a minor but useful extension of the first: foreach (array_expression as $value) statement foreach (array_expression as $key => $value) statement Link to comment https://forums.phpfreaks.com/topic/121141-problem-with-foreach-function/#findComment-624531 Share on other sites More sharing options...
ardyandkari Posted August 25, 2008 Author Share Posted August 25, 2008 ok... MasterACE14: i tried with one array and got the same error. also, at php.net, it is a lowercase as. PFMaBiSmAd : thank you for that, but i have already been to php.net and know about foreach... you can also do this foreach (array_expression as &$value) got that from php.net too...doesnt help much though... i got it to work...sort of. still doubles the number of days in the calendar...so i am scrapping that idea and will try again later. Link to comment https://forums.phpfreaks.com/topic/121141-problem-with-foreach-function/#findComment-624914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.