Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is the diffrence between for and foreach?

Answer Posted / anuradha

foreach sort of asbtracts away some of the complexity and is
usually easier. I use this whenever I don't need to know the
numeral index of the array or $key => $value won't provide
me with it.

for is the older C style where you must first perform a
count() so you know how many iterations the loop requires.
It is useful when you need to know the index, or to count
backwards or step through in different groups.

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to remove duplicate values from array using php?

1019


What are the two main string operators?

1041


What are the differences between GET and POST methods?

1067


What is super keyword in php?

1069


Do I need apache for php?

1074


What is session cookies php?

984


Which will check if a function exists?

1071


How to get no. of rows using MYSQL function?

1087


How to track user logged out or not? When user is idle?

926


Where is php code written?

983


What is uniqid php?

1040


Is empty array php?

1005


Can php use gettext?

1019


How do you execute a php script from the command line?

1039


What is the use of the function 'imagetypes()'?

1010