Skip to main content

Multiple variables access through foreach in php





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)




Comments

  1. if all array has same keys then

    foreach ($courses as $key => $course)
    {
    echo $sections[$key];
    echo $example[key];
    }

    ReplyDelete

Post a Comment

Popular posts from this blog

Wildcards in a hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost . The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local , site2.local etc, and have them all resolve to localhost , while Apache serves a different site accordingly.