News Feed
Sections




News Archive
feed this:

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

Ben Ramsey:
The Array_column() PHP Userland Library
July 08, 2013 @ 10:50:20

For those that may not be able to update to PHP 5.5 anytime soon but still want some of the cool features that come with it, there's one more option for adding that to your current PHP install. Ben Ramsey has released a userland-version of array_column, the function that returns the values from one column for all values in an array.

Earlier this year, I wrote about how my patch for array_column() was merged into the development branch for PHP 5.5 in preparation for the beta release. I received a lot of great feedback and many kind words. Then, on June 20, the PHP team announced the general availability version of 5.5.0. With that, array_column() was released to the world for general use.

Many still use earlier versions of PHP, though. While the functionality of array_column() is simple enough to implement on your own in userland code, I've released a small library that implements it in userland code exactly as it's implemented in the core, complete with the same PHP error messages and warnings.

The library has no dependencies and can be dropped into an existing application easily - just grab the source and include the needed file when you want to use the function (or it can be installed via Composer too).

0 comments voice your opinion now!
arraycolumn userland library release

Link: http://benramsey.com/blog/2013/07/the-array-column-php-userland-library

Ben Ramsey:
Introducing Array_column() in PHP 5.5
March 21, 2013 @ 10:46:01

Ben Ramsey has a new post talking about a feature that will become available in the PHP 5.5.x release series of the language - the array_column function. This function will extract all values from an array matching a given key.

My original patch for array_column() was written for PHP 5.2, but it sat around collecting dust for many years, until April of last year, when PHP moved to git and GitHub. That's when it became easy enough to apply the patch and send a pull request, which I did. [...] My goal for array_column() was simplicity. Many implement the functionality in different ways, and many call the function by other names (such as "pluck"), but I wanted to keep it simple and recognizable.

He includes an example of some sample data and how the function could be used to pull out the "last_name" field from each of the records and return just those as an array. If you're interested in seeing the original proposal and the RFC that was created for it, you can see it on the PHP wiki.

0 comments voice your opinion now!
arraycolumn array function index feature language



Community Events





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


framework api podcast deployment symfony package series release community voicesoftheelephpant opinion language list bugfix introduction interview library install laravel tips

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