0I have this string:
01, 02, 03, 04, 05, 06, 07, 08, 09
and I need to convert it in an associative array with the numbers as keys and the values set to 0
Array(
"01" => 0,
"02" => 0,
etc
)
I've found the function array_walk but if I try to use it: http://phpfiddle.org/main/code/5z2-bar
$string = "01, 02, 03, 04, 05, 06, 07, 08, 09";
$days = explode(",", $string);
$assDays = Array();
function associate($element)
{
$assDays[$element] = 0;
}
echo "<pre>";
print_r(array_walk($days, 'associate'));
echo "</pre>";
Doesn't work. I'm sure the problem is that I don't pass the values to the function associate but I don't know how to do.