marf Posted June 25, 2007 Share Posted June 25, 2007 when using mysql_fetch_array($result) I usually toss that into a while loop like so while($row = mysql_fetch_array($result)){ ... } however I was wondering if there was a way to put it in a foreach statement like so foreach(mysql_fetch_array($result) as $row){ ... } Is that legit? Will this work? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 25, 2007 Share Posted June 25, 2007 Nope, doesn't work...I'm not sure if there is some way to get it to though, there might be. I would just stick with the while loop =] Are you trying to achieve something you think your while loop can't? Quote Link to comment Share on other sites More sharing options...
marf Posted June 25, 2007 Author Share Posted June 25, 2007 I was just under the impression that a foreach loop's runtime is faster than while loop, the same way a Turnery operator is faster than an if/else Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 25, 2007 Share Posted June 25, 2007 for each is for array and theres things that the foreach cant do like for and while does so it depends on the situation Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.