Last active
September 15, 2020 01:01
-
-
Save design-innovations/6307bd860b0db8ebb3278fede9ee35e4 to your computer and use it in GitHub Desktop.
PHP - Closures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$touristPrices = array_map(function($price) { | |
return $price*2; | |
}, $localPrices); | |
// or | |
$factor = 2; | |
$touristPrices = array_map(function($price) use($factor) { | |
return $price*$factor; | |
}, $localPrices); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment