Download the PHP package rkr/php-array-utils without Composer
On this page you can find all versions of the php package rkr/php-array-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rkr/php-array-utils
More information about rkr/php-array-utils
Files in rkr/php-array-utils
Package php-array-utils
Short Description A array-function library
License MIT
Homepage http://github.com/rkrx/php-array-utils
Informations about the package php-array-utils
php-array-utils
A array-function library
FAQ
Hey, all the cool kids use OOP. Isn't this library pointing in the wrong direction?
It depends either on the situation or the extent in which an array is used. In PHP, arrays are often meat in different situations. At least, $_-variables are arrays. You can immediately wrap an Array into an ArrayObject, but then you can't use many of the features built into PHP directly. So I think I have to explain the advantages and disadvantages of each approach:
Advantage of array-functions:
- You don't have to make an object out of every array you wan't to apply certain functionality on.
- You can still use php's built in functions like array_merge() on arrays without the need for conversion.
- You can add as many functions by yourself as you wish. You could so the same with an ArrayObject-descendant, but then you end up with a god-object with tens or hundreds of methods (Closure-bindung?).
- You can always use the array-typehint and still utilize the extensions of this library directly.
Disadvantages of array-functions:
- Everytime you pass an array as a parameter to a function/method, the whole array gets copied.
- You can utilize an inner state that can help to track changes or whatever.