News Feed
Sections




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

Luc de Brouwer's Blog:
Stop waiting, start array dereferencing in PHP now!
September 07, 2010 @ 13:37:09

In this recent post to his blog Luc de Brouwer makes a recommendation about dereferencing your arrays - start thinking about it now even before the feature's added to the stable release!

Ever since I started programming object oriented PHP I've been using function chaining and function dereferencing. But there is another thing I'd like to be able to do that was added to the PHP trunk over 8 months ago that still hasn't made it to the current release. The function I'm referring to is array dereferencing.

The trick of dereferencing arrays is that you can pull out a value from a returned array without having to use another line of code (i.e. "foo()['a']"). His suggestion is that you start thinking that way now, but use a sort of hack function to pull it off - one that takes the array and a key and returns that value. There's other suggestions in the comments on how to do things differently though.

0 comments voice your opinion now!
array dereference function example


blog comments powered by Disqus

Similar Posts

Ahmed Shreef's Blog: Soap Web Services in PHP & hint on consuming from .Net

Michael Kimsal's Blog: Grails for PHP Developers Part 5

Alexey Zakhlestin's Blog: Ode to mb_ereg functions

IBuildings Blog: Multithreading in PHP with CURL

Shameer's Blog: PHP 5.3 : Practical look into Lambda functions and closures


Community Events





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


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

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