-1
foreach ($courses as $course, $sections as $section, $example as $example)

any ways to add more than 2?

i only know the solution to 2 variables.

foreach (array_combine($courses, $sections) as $course => $section)
vinz
  • 350
  • 2
  • 9
  • 19
  • You can only use foreach on one element per use. if you want to parse more than one array, either make one array that contains all the data (if you can do this without breaking the code, why would you have 3 arrays to begin with ? ) or make 3 separate calls to foreach. Some information on what you want to achieve would help – Raz Feb 10 '12 at 10:42

1 Answers1

3

if all array has same keys then

foreach ($courses as $key => $course)
{
    echo $sections[$key], $example[$key];
}
hakre
  • 193,403
  • 52
  • 435
  • 836
Gaurav
  • 28,447
  • 8
  • 50
  • 80