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

A process is identified by a unique___

1111


What is difference between isset and empty in php?

1045


How to create connection in php?

1052


What are the different types of statements that are present in php?

1066


What are default session time and path?

1190


Is php closing tag necessary?

1043


How to reset/destroy a cookie?

1204


How to track no of user logged in?

1058


How a constant is defined in a php script?

1042


Which is true about the singleton design pattern?

984


What is isset post?

1067


What is the difference between htmlentities() and htmlspecialchars()?

1050


Can we extend two classes in php?

1112


Write a select query that will be displayed the duplicated site name and how many times it is duplicated?

1074


Why is used in php?

996