Dealing with php 5.3 undefined index errors

I had an old php custom report that pulls data from a mysql db and I was getting “undefined index” errors when we moved to PHP 5.3.
This function helped:


But I also had to pre-set an array with all the default values.
Before I had

$totalColumn = array();

but now I had to set the default value for each column:

$totalColumn = array("minority_check" => 0, "count" => 0, "applicant_total" => 0, "Men_total" => 0, "Women_total" => 0, "men_women_total" => 0, "percent_of_women_to_total" => 0, "white_total" => 0, "white_plus_other_race_total" => 0,
	 "white_plus_other_race_AND_hispanic_total" => 0, "white_AND_hispanic_total" => 0, "multirace_AND_hispanic_total" => 0, "protected_class_AND_hispanic_total" => 0, "protected_class_but_not_white_AND_hispanic_total" => 0,
	 "declined_race_but_hispanic_total" => 0, "declined_to_ident_total" => 0, "declined_to_id_hispanic_total" => 0, "declined_to_ident_race_with_hispanic_total" => 0, "declined_to_ident_race_and_hispanic_total" => 0,
	 "declined_to_ident_race_OR_hispanic_total" => 0, "protected_class_total" => 0, "hispanic_total" => 0, "minority_total" => 0, "known_race_OR_hispanic_total" => 0, "percent_of_minority_to_total" => 0, "white_undeclared_minority_total" => 0,
	 "non_hispanic_total" => 0, "asian_total" => 0, "pacific_total" => 0, "black_total" => 0, "native_american_total" => 0, "multiracial_total" => 0, "multiracial_and_or_hispanic_total" => 0);
Leave a Comment