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']
]
This has nothing to do with your text editor. It has to do with your PHP versions. Your development environment is running PHP 5.4+ and your production environment is running PHP 5.3 or older which does not support short array syntax (i.e.
[]
) which was introduced in PHP 5.4.So
needs to become
to become backwards compatible.