• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Hosting-new.com

Hébergement web, cloud et solutions personnalisées

  • Home
  • About

Hébergement CPanel sur SSD, offre Cloud

Un hébergement professionnel sur serveur Xeon Gold et SSD

PHP Tutorial – 14 – Foreach Array Loops

April 5, 2011 by Admin 25 Comments

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

visit www.thenewboston.com for all my tutorials!
Video Rating: 4 / 5

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

Filed Under: Php Tagged With: Array, Foreach, Loops, Tutorial

Reader Interactions

Comments

  1. hammadghulam says

    April 5, 2011 at 11:41 am

    let me foreach myself……………..

    Reply
  2. HawxTeamDelta says

    April 5, 2011 at 12:27 pm

    wow this is useful for making calendar

    Reply
  3. keirnus says

    April 5, 2011 at 1:14 pm

    for each elements of $test is treated as $x (one at a time starting from the 1st) and echoed.

    Reply
  4. TheEliseoReyes says

    April 5, 2011 at 1:54 pm

    Great video!

    Reply
  5. COMMANO38 says

    April 5, 2011 at 2:34 pm

    I love the foreach loop :p

    Reply
  6. nwas555 says

    April 5, 2011 at 2:39 pm

    thank you very much for this useful tutorial
    Waled

    Reply
  7. imwithswat says

    April 5, 2011 at 3:29 pm

    CHECK OUT MY CHANEL TO LEARN HOW TO LEARN IT IN ABOUT 17 HOURS

    Reply
  8. hesham3540 says

    April 5, 2011 at 4:23 pm

    like the enhanced for loop in java ! thanks bucky

    Reply
  9. coolcam262 says

    April 5, 2011 at 5:03 pm

    Thank you so much…

    Reply
  10. TheRealAuxiliary says

    April 5, 2011 at 6:00 pm

    Usefull for making websites 🙂

    Reply
  11. mangoprojects says

    April 5, 2011 at 6:44 pm

    Genius. – BehindVFX

    Reply
  12. mangoprojects says

    April 5, 2011 at 7:14 pm

    Genius. – BehindVFX

    Reply
  13. mangoprojects says

    April 5, 2011 at 7:18 pm

    Genius. – BehindVFX

    Reply
  14. TheErroneousOne says

    April 5, 2011 at 8:02 pm

    I would think it’s pretty confusing to the viewer that you keep switching from using single ‘ marks from quotation ” marks. I don’t know PHP very well, but I’m assuming they are some-what interchangeable. The viewer may not though.

    Reply
  15. cocodibani says

    April 5, 2011 at 8:37 pm

    nice

    Reply
  16. cocodibani says

    April 5, 2011 at 8:49 pm

    I’m unsure on how to structure a code correctly to give a command within my WHILE loop after executing an IF statement, can you take a look at this thread i posted? tinyurl [dot] com/y8e8jod thank you

    Reply
  17. larobertson04 says

    April 5, 2011 at 8:53 pm

    I was thinking the same thing.

    Reply
  18. onnoman says

    April 5, 2011 at 9:36 pm

    What is the reason you get arrayarrayarray when you do: echo $test;?

    Reply
  19. CL0udnyn3 says

    April 5, 2011 at 10:17 pm

    I like Array_values as it offers a more complex and detailed view of the array but for a simple view the foreach and for loops you showed work.

    Reply
  20. CL0udnyn3 says

    April 5, 2011 at 10:57 pm

    I don’t understand the significance of $x in PHP as when I change my variable letter to anything other than x it won’t display so i figure $x is something special in PHP?

    Reply
  21. iamtheeskimofriend says

    April 5, 2011 at 11:05 pm

    I agree. If you are going to teach, you need to teach proper syntax. It’s the equivalent to a biology teacher leaving out connective tissue, an english teacher leaving out periods and a math teacher leaving out parentheses that are necessary to solve a problem in the correct order. It would also be useful to explain why a foreach statement is useful in a real world application, because your example doesn’t give the foreach statement the merit it deserves.

    Reply
  22. iamtheeskimofriend says

    April 5, 2011 at 11:52 pm

    Imagine you have a database where there are a LOT more values (hundreds or thousands) it’s far less complicated to type than the for statement.

    Reply
  23. zimant78 says

    April 6, 2011 at 12:27 am

    well that was abit of a mysterious tutorial as the webpage readout for your code was three. so $x was just the last element of the array, i didnt understand why! thanks no worries i will find out with 5 mins of reading!

    Reply
  24. r3sp3c791 says

    April 6, 2011 at 12:38 am

    Can somebody tell me for what usefull think I can use that “foreach” because I don’t find sence in it

    Reply
  25. mKornelius says

    April 6, 2011 at 1:12 am

    Yeah, very nice work there.
    All ready learned alot. And will continue watching your video’s. And hopefully you will keep up the good work? 🙂

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CAPTCHA
Refresh

*

Primary Sidebar

Made with love by Hosting-New