3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $combined = array( 'A' => array( 'B' => array( 'C' => array(null, null), ), 'D' => array( 'K' => array(null, null), ) ), ); $stack = array(&$combined); while (null !== ($ptr = &array_pop($stack))) { $null_count = 0; foreach ($ptr as $key => $value) { if (is_array($value)) { $stack[] = &$ptr[$key]; } elseif (null === $value) { ++$null_count; } } if (count($ptr) === $null_count) { $ptr = null; } } print_r($combined);
Output for 4.4.0 - 4.4.9, 7.0.0 - 7.1.0
Notice: Only variables should be assigned by reference in /in/7Oh09 on line 14 Notice: Only variables should be assigned by reference in /in/7Oh09 on line 14 Notice: Only variables should be assigned by reference in /in/7Oh09 on line 14 Notice: Only variables should be assigned by reference in /in/7Oh09 on line 14 Notice: Only variables should be assigned by reference in /in/7Oh09 on line 14 Notice: Only variables should be assigned by reference in /in/7Oh09 on line 14 Notice: Only variables should be assigned by reference in /in/7Oh09 on line 14 Array ( [A] => Array ( [B] => Array ( [C] => Array ( [0] => [1] => ) ) [D] => Array ( [K] => Array ( [0] => [1] => ) ) ) )
Output for 5.0.5 - 5.6.28
Strict Standards: Only variables should be assigned by reference in /in/7Oh09 on line 14 Strict Standards: Only variables should be assigned by reference in /in/7Oh09 on line 14 Strict Standards: Only variables should be assigned by reference in /in/7Oh09 on line 14 Strict Standards: Only variables should be assigned by reference in /in/7Oh09 on line 14 Strict Standards: Only variables should be assigned by reference in /in/7Oh09 on line 14 Strict Standards: Only variables should be assigned by reference in /in/7Oh09 on line 14 Strict Standards: Only variables should be assigned by reference in /in/7Oh09 on line 14 Array ( [A] => Array ( [B] => Array ( [C] => Array ( [0] => [1] => ) ) [D] => Array ( [K] => Array ( [0] => [1] => ) ) ) )
Output for 4.3.0 - 4.3.11, 5.0.0 - 5.0.4
Array ( [A] => Array ( [B] => Array ( [C] => Array ( [0] => [1] => ) ) [D] => Array ( [K] => Array ( [0] => [1] => ) ) ) )