PHP Functional Programming Assignment to variables

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Anonymous functions can be assigned to variables for use as parameters where a callback is expected:

$uppercase = function($data) {
    return strtoupper($data);
};

$mixedCase = ["Hello", "World"];
$uppercased = array_map($uppercase, $mixedCase);
print_r($uppercased);

These variables can also be used as standalone function calls:

echo $uppercase("Hello world!"); // HELLO WORLD!


Got any PHP Question?