I've read that it makes no sense to push new key value pairs into arrays. But how could this situation be solved best?
I have a multidim array of tutor and courses data:
$data = [
['tutor_name' => 'John Doe', 'course_day' => 'Monday', ...],
['tutor_name' => 'John Doe', 'course_day' => 'Tuesday', ...]
...
];
I need to translate all the days into my language (cz) so I wrote a switch:
function translate_to_cz ($day) {
switch ($day) {
case "Monday":
$day_cz = "Pondělí";
break;
case "Tuesday":
$day_cz = "Úterý";
break;
...
}
return $day_cz;
}
I need a loop that would send $data['course_day'] to the switch. The $day_cz would then be returned to the original array, preferably with a new key $data['course_day_cz'] waiting for it. Can this be done? Thanks