I'm doing a loop thro XML and collecting data from it. Some values need to be translated so i've made a switch function, which is wrapped inside another function and called on every loop to check the original value and change it according defined new value within the switch.
The problem is if i include the switch inside the foreach the original value get's changed properly (strings of the original variable $foo are translated). But if i wrap the switch in function and call that function within the loop then the original value doesn't get changed. It needs to be if ($foo == 'one') $foo == 'ein'
... Here's my code:
function checkTranslation($foo) {
switch($foo) {
case('one'): $foo = 'ein'; break;
case('two'): $foo = 'zwei'; break;
...
}
};
foreach ($XML -> some -> data as $item) {
$foo = $item['value'];
checkTranslation($foo);
}