/** * Helper function that returns the multiple serialized DataTable of the given PHP array. * The DataTable here associates a subtable to every row of the level 0 array. * This is used for example for search engines. Every search engine (level 0) has a subtable containing the * keywords. * * The $arrayLevel0 must have the format * Example: array ( * LABEL => array(col1 => X, col2 => Y), * LABEL2 => array(col1 => X, col2 => Y), * ) * * The $subArrayLevel1ByKey must have the format * Example: array( * LABEL => #Piwik_DataTable_ForLABEL, * LABEL2 => #Piwik_DataTable_ForLABEL2, * ) * * * @param array $arrayLevel0 * @param array of Piwik_DataTable $subArrayLevel1ByKey * @return array Array with N elements: the strings of the datatable serialized */ public function getDataTablesSerialized($arrayLevel0, $subArrayLevel1ByKey) { $tablesByLabel = array(); foreach ($arrayLevel0 as $label => $aAllRowsForThisLabel) { $table = new Piwik_DataTable(); $table->loadFromArrayLabelIsKey($aAllRowsForThisLabel); $tablesByLabel[$label] = $table; } $parentTableLevel0 = new Piwik_DataTable(); $parentTableLevel0->loadFromArrayLabelIsKey($subArrayLevel1ByKey, $tablesByLabel); // echo $parentTableLevel0; $toReturn = $parentTableLevel0->getSerialized(); return $toReturn; }