I come from a JS world and have trouble understanding this piece of code:
function getCountryName($code, $codes){
print_r($code);
array_filter(
$codes,
function ($e) {
if($e->cca2 == $code){
print_r($e->name->common);
}
}
);
}
The second line is for debug only and it prints given $code. But here: if($e->cca2 == $code){ $code seems to be undefined. How is it even possible? It works with $GLOBALS['code'] but I don't want to use globals. How come array_filter has no access to it's own scope?