3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $cars=array("Dodge"=>array("Avenger","Challenger","Charger","Dart"),"Toyota"=>array("Highlander","Tundra","Corolla"),"Nissan"=>array("Sentra","Altima","Maxima")); echo "Make: Toyota"; echo "<br><br>"; $first = TRUE; $cars = ''; foreach($cars['Toyota'] as $x){ if ($first){ $cars .= $x; }else{ $cars = ", $x"; } } echo $cars; ?>
Output for 5.5.0 - 5.6.21, 7.0.0 - 7.1.0
Make: Toyota<br><br> Warning: Illegal string offset 'Toyota' in /in/pKk9V on line 8 Notice: Uninitialized string offset: 0 in /in/pKk9V on line 8 Warning: Invalid argument supplied for foreach() in /in/pKk9V on line 8
Output for hhvm-3.10.0 - 3.12.0
Make: Toyota<br><br> Warning: Invalid argument supplied for foreach() in /in/pKk9V on line 14
Output for 5.4.0 - 5.4.45
Make: Toyota<br><br> Warning: Illegal string offset 'Toyota' in /in/pKk9V on line 8 Warning: Invalid argument supplied for foreach() in /in/pKk9V on line 8
Output for 5.2.3 - 5.3.29
Make: Toyota<br><br> Warning: Invalid argument supplied for foreach() in /in/pKk9V on line 8
Output for 5.2.1 - 5.2.2
Make: Toyota<br><br><br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/in/pKk9V</b> on line <b>8</b><br />
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.2.0
Make: Toyota<br><br><br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/in/pKk9V</b> on line <b>8</b><br /> Array
Output for 4.3.11
Make: Toyota<br><br>Array