How to use the foreach statement in PHP

PHP has several loops and conditional statements that have been part of the language since its inception. Unlike them, the foreach statement was introduced in PHP later, influenced by other programming languages to be used for foreach years. Unlike the other loop and conditional statements, the foreach statement is only used in arrays.

Use the Declaration foreach PHP

Create the matrix: $ arr = array (1, 2, 3, 4);

Write status: foreach ($ arr as $ i => $ value)

Write action will be taken. In this case, the action is to multiply the initial value of 10: ($ arr [$ i] = $ value * 10;)

Check Declaration

Check your code syntax errors.

Make sure your parent has the following values: 10, 20, 30, 40.

Featured Links:

Google Payload
Proven Money Maker At $9,547 A Day.
Burn The Fat Feed The Muscle
Burn The Fat - Top Selling Fat Loss Ebook Since 2003.
Save My Marriage Today!
Have You Ever Stayed Awake at Night Stressing About Whether or Not Your Marriage Will Last ... And What You Can Possibly Do to Save It?
Ultra Hot* SpywareBot: #1 AntiSpyware
Scan your computer for hidden AdWare and Spyware, Remove them permanently.
Top Movie Downloads
Join the Internet revolution and start downloading free movies and more!
Get Google Pay-Per-Click Ads Free!
Internet Marketer Gets $87 Million in Google Pay-Per-Click Ads FREE! ... And Makes Over $314 Million as a Result! ...And Now He's Going to Give You This Same Secret for Next to Nothing!
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • StumbleUpon
  • TwitThis

Leave a comment

You must be logged in to post a comment.