@ 2015-12-17T00:38:35Z <?php
function isEmptyArray($item) {
if (is_array($item)) {
return array_filter($item, 'isEmptyArray');
}
if (!empty($item) || $item === "0") {
return true;
}
return false;
}
function removeEmptyArrays($array)
{
$filteredArray = array_filter($array, 'isEmptyArray');
return $filteredArray;
}
function isMultiDimensional($array)
{
if(is_array($array)) {
foreach ($array as $key=>$value){
if(is_array($value)){
return true;
}
}
}
return false;
}
$options_array = array("acct"=>array("acct_row"=>array("billing_group"=> array ("billing_group_row"=> array ('0' => array("billing_group_name"=>"", "billing_group_description"=> "", "list_start_master_file"=> "0" ))))));
$options = array();
$apiLiveOptions = array();
foreach ($options_array AS $key => $value) {
if (is_array($value)) {
if (!empty($value[$key])) {
$options[$key] = $value;
$apiLiveOptions[$key] = $value;
} else {
$array = array();
$apiLiveArray = array();
foreach ($value as $k => $v) {
if(!empty($v[$k])) {
$array[] = $value[$k];
$apiLiveArray[] = $value[$k];
$options[$key] = $array;
} else {
$newArray = array_filter($v, 'removeEmptyArrays');
$apiLiveArray[$k] = $newArray;
foreach($newArray as $row => $column) {
if(is_array($column)) {
var_dump($column);
foreach($column as $r=>$c) {
$options[$row][$r]=$c;
}
} else {
$array[$k]=$column;
$options[$row] = $array;
}
}
}
}
$apiLiveOptions[$key] = $apiLiveArray;
}
} else {
$options[$key] = $value;
$apiLiveOptions[$key] = $value;
}
};
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.10 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 array(1) {
["billing_group_row"]=>
array(1) {
[0]=>
array(3) {
["billing_group_name"]=>
string(0) ""
["billing_group_description"]=>
string(0) ""
["list_start_master_file"]=>
string(1) "0"
}
}
}
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
array(1) {
["billing_group_row"]=>
array(1) {
[0]=>
array(3) {
["billing_group_name"]=>
string(0) ""
["billing_group_description"]=>
string(0) ""
["list_start_master_file"]=>
string(1) "0"
}
}
}
preferences:dark mode live preview
157.56 ms | 402 KiB | 181 Q