Project

General

Profile

« Previous | Next » 

Revision 4fadd759

Added by Andreas Kohlbecker about 3 years ago

method to check variables for isset & not empty - improvement and similar method for numerical vals only

View differences:

modules/cdm_dataportal/includes/common.inc
921 921
 * @return bool
922 922
 *  True if the variable is set and is not NULL an is not empty.
923 923
 */
924
function isset_not_empty(&$var){
924
function isset_not_empty(&$var, $numerical_non_zero = FALSE){
925 925
  if (!isset($var)){
926 926
    return false;
927 927
  }
928 928
  if(is_numeric($var)) {
929
    return true;
929
    if($numerical_non_zero){
930
      return $var;
931
    } else {
932
      true;
933
    };
930 934
  } else if(is_array($var)){
931 935
    return count($var) > 0;
932 936
  }else if(is_string($var)){
......
934 938
  } else {
935 939
    return !!$var;
936 940
  }
941
}
937 942

  
943
function isset_numerical(&$var){
944
  if (!isset($var)){
945
    return false;
946
  }
947
  return is_numeric($var);
938 948
}
949

  

Also available in: Unified diff