- 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() {
$timeOfDay = "morning";
return (function($name) {
return ("Boa Tarde, $name!");
});
};
$greetingFunction = getGreetingFunction();
echo $greetingFunction("Frederico"); // "Bom dia, Frederico!"