Download the PHP package xp-forge/pivot without Composer
On this page you can find all versions of the php package xp-forge/pivot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xp-forge/pivot
More information about xp-forge/pivot
Files in xp-forge/pivot
Package pivot
Short Description Pivot table
License BSD-3-Clause
Homepage http://xp-framework.net/
Informations about the package pivot
Pivot table
Working with pivot tables
Example
Given the following input, e.g. from a logfile:
We will parse this using sscanf()
, transforming the lines into arrays like the following:
We can the load this into our pivot table using the array offsets (if we had a map, we could use its string keys; for objects we'll pass references to the getters and for more complex situations we can pass closures). Putting it together, we get the following:
The resulting table will look something like this (using "b:" as an abbreviation for bytes - this becomes relevant once we sum on multiple columns):
Accessing values in a pivot
The number of records grouped by the grouping columns can be retrieved via count()
. The aggregates can be accessed by passing the category to the respective methods.
Drill down
We can dril down by the categories we grouped on by using the rows()
method. To calculate the distribution of categories in percent of the total, we'll use the count()
method.
It can also interesting to see a development over time, so we'll drill down based on the columsn instead.
All versions of pivot with dependencies
xp-forge/sequence Version ^10.0 | ^9.0 | ^8.0 | ^7.0 | ^6.0 | ^5.0
php Version >=7.0.0