Hi all,
I have just coded this for my website, is there a way to improve this either by extending for a more general use or just improving my logic's. Thank you in advance.
function removeEmptyArray($array, $remove_null_number = true) {
$new_array = array();
$null_exceptions = array();
foreach ($array as $key => $value) {
$value = trim($value);
if($remove_null_number) {
$null_exceptions[] = '0';
}
if(!in_array($value, $null_exceptions) && $value != "") {
$new_array[] = $value;
}
}
return $new_array;
}
function ifValue($value, $suffix="", $prefix="", $returnvalue=true) {
$value = removeEmptyArray($value);
if (!empty($value)) {
foreach ($value as $item) {
$return .= $item." ";
}
if ($returnvalue) {
return $prefix.trim($return).$suffix;
} else {
return $prefix.$suffix;
}
} else {
$return = "";
return $return;
}
}