joomla-framework/data — pull request #2 by rkgrep (2014-08-27 18:00:08+00:00)
Title: DataSet::toArray() method added

A method to extract data from DataSet as custom array.
Example:

$set = new DataSet(array(
new DataObject(array('date'=>'1990', 'projects'=>5, 'employees'=>50)),
new DataObject(array('date'=>'2000', 'projects'=>12, 'employees'=>140)),
new DataObject(array('date'=>'2010', 'projects'=>11, 'employees'=>110))
));
echo json_encode($set->toArray(false, 'date', 'projects'));
echo json_encode($set->toArray());

In first case the return will be `[["1990",5],["2000",12],["2010",11]]`
In second case a full dump of DataSet in json format.

The method is very usefull when data from a set is to be inserted into database or extracted in custom format.