Arrays are an integral part of PHP and we constantly use them when building Joomla! extensions. PHP provides us with a number of very useful functions for working with arrays. We can use the static
JArrayHelper class to simplify other common tasks when working with arrays.
JArrayHelper class is located in the
joomla.utilities.arrayhelper library. Before we can use the
JArrayHelper class we must import the relevant library:
Imagine we have a CSV file, which holds records with mathematical data:
2, 4.6 0, 0.0 1, 2.5 4, 8.2
Now imagine we want to order the data by ID (the first field) and we want the values (second field) to be displayed as integers.
The first thing we need to do is retrieve the contents ...