You are here

function ChartsGraphsFlashCanvas::merge_xml_values in Charts and Graphs 7

Same name and namespace in other branches
  1. 6.2 charts_graphs_flash_canvas.class.inc \ChartsGraphsFlashCanvas::merge_xml_values()

Merges the two arrays.

The final array will be a copy of the second array with the values of the first whose IDs are not present in the second.

IDs of the second array with a value of NULL are not included but these same IDs are not copied from the first array, so they effectivelly delete settings from the first array.

Parameters

<array> $first:

<array> $second:

Return value

<array>

3 calls to ChartsGraphsFlashCanvas::merge_xml_values()
ChartsGraphsAmcharts::get_chart in apis/charts_graphs_amcharts/charts_graphs_amcharts.class.inc
Function that renders data.
ChartsGraphsAmcharts::_preprocess_values_not_pie in apis/charts_graphs_amcharts/charts_graphs_amcharts.class.inc
ChartsGraphsAmcharts::_preprocess_values_pie in apis/charts_graphs_amcharts/charts_graphs_amcharts.class.inc

File

./charts_graphs_flash_canvas.class.inc, line 48
abstract class ChartsGraphsFlashCanvas.

Class

ChartsGraphsFlashCanvas
Abstract class to be derived for Flash based charting libraries.

Code

function merge_xml_values($first, $second) {

  //    dpm($first, '$first');
  //    dpm($second, '$second');
  $second_ids = array();
  foreach ($second as $value) {
    $second_ids[$value['#id']] = TRUE;
  }
  $final = array();
  foreach ($first as $value) {
    if (!isset($second_ids[$value['#id']])) {
      $final[] = $value;
    }
  }
  foreach ($second as $value) {
    if (isset($value['#value']) && $value['#value'] === NULL) {
      continue;
    }
    $final[] = $value;
  }
  return $final;
}