News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso's Blog:
Real-life example of Closure usage with PHP5.3
December 07, 2010 @ 15:31:35

Gonzalo Ayuso has posted his real-life example of closures in a PHP 5.3 application rather than some of the syntax-only based examples from several other sites around the web.

One of the new improvements in new PHP5.3 version are the Closures. Here you are a real-life example where closures are really useful for me.

His example shows how to work with a nested array of data from a SQL query and walk through it using the array_walk function and a closure as a call back. Using the "use" keyword allows it to pull in values from outside the closure's scope and process the quantity, amount and price values to calculate totals.

0 comments voice your opinion now!
calculate closure reallife example feature


blog comments powered by Disqus

Similar Posts

Stuart Herbert's Blog: Quick Tip: Get, Set and Query in One Method

Gonzalo Ayuso's Blog: Real-life example of Closure usage with PHP5.3

Blue Parabola Blog: Magento Feature Analysis Series, Part 2: Product Browsing Offering

Sean Coates' Blog: Arbitrary Incrementer in PHP

Nick Halstead's Blog: Programming Tips #9 "debug_backtrace"


Community Events





Don't see your event here?
Let us know!


unittest library laravel install wordpress interview framework release api community bugfix threedevsandamaybe language list introduction developer application podcast series configure

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework