3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array( '' => 'foo', 'foo' => '', null, array(), 1, true, false, ); foreach($a as $k => $v) { echo "$k => $v\n"; var_dump(!empty($a[$k])); var_dump(isset($a[$k]) && $a[$k]); }
based on IbZu9
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
=> foo bool(true) bool(true) foo => bool(false) bool(false) 0 => bool(false) bool(false) Notice: Array to string conversion in /in/u3cvg on line 13 1 => Array bool(false) bool(false) 2 => 1 bool(true) bool(true) 3 => 1 bool(true) bool(true) 4 => bool(false) bool(false)
Output for 4.3.0 - 5.3.29
=> foo bool(true) bool(true) foo => bool(false) bool(false) 0 => bool(false) bool(false) 1 => Array bool(false) bool(false) 2 => 1 bool(true) bool(true) 3 => 1 bool(true) bool(true) 4 => bool(false) bool(false)