Home / PHP Tips Generated By ChatGPT / Using foreach with Associative Arrays in PHP Iterate over an associative array with foreach. Source Code $ages = ['Peter' => 41, 'John' => 30, 'Jane' => 29]; foreach ($ages as $name => $age) { echo "$name is $age years old.n"; }