[RESOLVED]Simple array_push not working as expected
Posted: Mon Jun 23, 2008 9:43 am
$arr_hour = ("8.00/0", "8.00/0", "2.00/0", "8.00/0", "2.00/0", "0/0", "2.00/0", "0/0", "2.00/0") ;
OUTPUT:
Array ( )
I can print $arr_hour_splitted inside the function and it displays what it's supposed to,
so it does go through the array_walk function just fine. But why is it not pushing the
the strings into the new array?
Code: Select all
// variables declared here so accessible outside function scope
$arr_hour_regular = array();
$arr_hour_overtime = array();
// goes through each hour item and splits it into overtime and regular, then pushes them into their resp. arrays
function splitHours($hour_item, $hour_key, $delim) {
$arr_hour_splitted = explode ($delim, $hour_item);
array_push ($arr_hour_regular, $arr_hour_splitted[0]);
//$arr_hour_overtime[] = $arr_hour_splitted[1];
}
array_walk ($arr_hours, "splitHours", "/");
print_r ($arr_hour_regular);Array ( )
I can print $arr_hour_splitted inside the function and it displays what it's supposed to,
so it does go through the array_walk function just fine. But why is it not pushing the
the strings into the new array?