3v4l.org

run code in 300+ PHP versions simultaneously
<?php function addArrayIfNotEmpty($entire_array, $key, $childArray){ count($childArray) ? $entire_array[$key] = $childArray : null; return $entire_array; } $entire_array = array(); $entire_array = addArrayIfNotEmpty($entire_array, 'key1', array()); print_r($entire_array); $entire_array = addArrayIfNotEmpty($entire_array, 'key2', array('hello')); print_r($entire_array);

preferences:
24.49 ms | 404 KiB | 5 Q