Is there something wrong with $data[$key][$val] = [];
, because on localhost it works nice but on server it doesnt (Wordpress shows blank page, and I noticed that it breaks just on that line)
$months = array('sijecanj' => 'Siječanj', 'veljaca' => 'Veljača', 'ozujak' => 'Ožujak', 'travanj' => 'Travanj'...);
$parts = array('Plodovi' ,'Korijen', 'Kora', 'Sjeme');
$data = array();
foreach($months as $key => $val) {
$data[$key][$val] = [];
foreach($parts as $part) {
if( has_term( $part, $key ) ) {
array_push($data[$key][$val], $part);
}
}
}
What I am trying to do is to have an array for each month if it has some values with specific parts, while also pertaining key-value pairs for months. (I need key as slug for fetching data from Wordpress database and value will be echoed'), so that in the end I get something like this
$data = [
'Siječanj' => ['Plodovi', 'Korijen'],
'Kolovoz' => ['Kora', 'Sjeme']
]