- print_r: documentation ( source)
<?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);