3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $result = $db->query('SELECT * FROM table.logs ORDER BY time DESC LIMIT 2'); while ($item = $db->fetch_assoc($result)) { /* data (var_export) array ( 'id' => '183970', 'player1' => 'Weird', 'player2' => 'Bloodbuddy', 'player1_items' => '644:204,10:200000,', 'player2_items' => '38:200,', )array ( 'id' => '183969', 'player1' => 'Frog', 'player2' => 'Eh', 'player1_items' => '656:1,11:3797,33:1111,42:200,40:100,31:1111,1263:1,522:1,', 'player2_items' => '405:1,', ) */ $player1_items = explode(':', $item['player1_items']); foreach ($player1_items as $key => $value) { echo $value; } }
Output for 7.0.28 - 7.3.0rc3
Notice: Undefined variable: db in /in/FUf1I on line 3 Fatal error: Uncaught Error: Call to a member function query() on null in /in/FUf1I:3 Stack trace: #0 {main} thrown in /in/FUf1I on line 3
Process exited with code 255.
Output for hhvm-3.22.0
Notice: Undefined variable: db in /in/FUf1I on line -1 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function query() on a non-object (null)' in /in/FUf1I:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Notice: Undefined variable: db in /in/FUf1I on line 3 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function query() on a non-object (null)' in /in/FUf1I:3 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Notice: Undefined variable: db in /in/FUf1I on line 3 Fatal error: Call to a member function query() on null in /in/FUf1I on line 3
Process exited with code 255.