- array_map: documentation ( source)
- print_r: documentation ( source)
- ucfirst: documentation ( source)
<?php
$names = array('Hugo', 'Manuel');
print_r(
array_map(
function($name) {
return "Olá, " . ucfirst($name) . "!";
},
$names)
);
function getGreetingFunction($welcomeMsg) {
return (function($name) use($welcomeMsg) {
return ("$welcomeMsg $name!");
});
};
$greetingFunction = getGreetingFunction('Boa tarde');
echo $greetingFunction("Frederico");