3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $my_employees_1 = array ( "Bob" => "37", "Jane" => 22, "Tom" => 58, "Amanda" => 41 ); $my_employees_2=$my_employees_1; asort($my_employees_2); $my_employees_3 =$my_employees_1; ksort($my_employees_3); foreach($employee_age2 as $a => $v); { print ("<p>Employee $a is $v years old</p>"); } // foreach($employee_age3 as $a => $v); { print ("<p>Employee $a is $v years old</p>"); }// print the elements of my_employees_3 ?>
Output for 5.1.0 - 7.2.0
Notice: Undefined variable: employee_age2 in /in/kQAnj on line 8 Warning: Invalid argument supplied for foreach() in /in/kQAnj on line 8 Notice: Undefined variable: a in /in/kQAnj on line 9 Notice: Undefined variable: v in /in/kQAnj on line 9 <p>Employee is years old</p> Notice: Undefined variable: employee_age3 in /in/kQAnj on line 11 Warning: Invalid argument supplied for foreach() in /in/kQAnj on line 11 Notice: Undefined variable: a in /in/kQAnj on line 12 Notice: Undefined variable: v in /in/kQAnj on line 12 <p>Employee is years old</p>
Output for 5.0.4 - 5.0.5
Warning: Invalid argument supplied for foreach() in /in/kQAnj on line 8 Notice: Undefined variable: a in /in/kQAnj on line 9 Notice: Undefined variable: v in /in/kQAnj on line 9 <p>Employee is years old</p> Warning: Invalid argument supplied for foreach() in /in/kQAnj on line 11 Notice: Undefined variable: a in /in/kQAnj on line 12 Notice: Undefined variable: v in /in/kQAnj on line 12 <p>Employee is years old</p>
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.0.3
Warning: Invalid argument supplied for foreach() in /in/kQAnj on line 8 Notice: Undefined variable: a in /in/kQAnj on line 9 Notice: Undefined variable: v in /in/kQAnj on line 9 <p>Employee is years old</p> Warning: Invalid argument supplied for foreach() in /in/kQAnj on line 11 Notice: Undefined variable: a in /in/kQAnj on line 12 Notice: Undefined variable: v in /in/kQAnj on line 12 <p>Employee is years old</p>
Output for 4.3.11
Notice: Undefined variable: a in /in/kQAnj on line 9 Notice: Undefined variable: v in /in/kQAnj on line 9 <p>Employee is years old</p> Notice: Undefined variable: a in /in/kQAnj on line 12 Notice: Undefined variable: v in /in/kQAnj on line 12 <p>Employee is years old</p>