tag:blogger.com,1999:blog-9088824.post8777036643195117089..comments2024-03-12T19:33:04.136+10:30Comments on Daniel O'Connor: php style: foreach is betterUnknownnoreply@blogger.comBlogger1125tag:blogger.com,1999:blog-9088824.post-59712604536701934002007-06-03T22:26:00.000+09:302007-06-03T22:26:00.000+09:30Too true!The for loop is overused, unnecessary, me...Too true!<BR/><BR/>The for loop is overused, unnecessary, messy and takes longer to type then a foreach loop.<BR/><BR/>I have always used foreach and the only reason i would need a for is if i needed a incrementing value, so if i need a incrementing value i either use the $key if it's a numerical value or i do a manual increment like so....<BR/><BR/><BR/>$count = 0;<BR/>foreach ($foo as $bar)<BR/>{<BR/>// Do Stuff with count<BR/>$count++;<BR/>}<BR/><BR/><BR/>Great article, thanks for sharing!Anonymousnoreply@blogger.com