clarence / matrix
Matrix -- a simple way to write fluent codes handing 2D data -- handling array of array is so easy!
v1.0.0
2016-05-25 10:02 UTC
Requires
- php: >=5.5
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2025-01-04 20:47:09 UTC
README
Matrix - yet another tool for operating arrays, especially two-dimensional arrays.
Usage
Provided a data source containing two columns - productId and productName, if only rows whose productId is bigger than 5 are needed, and if a key-value structure (key is productName) is needed, it can be solved like this:
$data = Matrix::from($dataSource)
->select(array('productId' => 'id', 'productName'))
->where(function ($row) {
return $row['id'] > 5;
})
->orderBy('id', SORT_DESC)
->indexedBy('productName')
->toArray();