Site menu

CodeCook.io

  • Languages
    • C
    • C++
    • CSS
    • Git
    • HTML
    • Java
    • JavaScript
    • jQuery
    • PHP
    • Python
    • Ruby
    • Scala
  • basic
  • for
  • loop

PHP - For each loop

Loop over all elements in list.

Code that executes each itteration
0
444
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Loop over array values

foreach ({{list}} as $value)
    {{body}}
php

Notes

last update: June 16, 2015

0
444
  • Share on Facebook
  • Share on Google+
  • Share on Twitter

Loop over key value pairs

foreach ({{list}} as $key => $value)
    {{body}}
php

Notes

last update: June 16, 2015

Advertisement

This project is hosted on DigitalOcean, try it and support us

Related concept

  • Counter loop
  • Hello world
  • Break out of loop
  • Class definition
  • Loop while condition is true
  • Do loop while a condition is true

Other language

  • Scala
  • Python
  • JavaScript
  • jQuery
  • AngularJS
  • Javascript ES6

Random task

  • Box-sizing
  • Set computer name
  • Inline conditional
  • Drop all git stash entries
  • Remove duplicates from list
  • Blog
  • About
  • License