It's a little hard to understand your question, but I'm imagining you're after results like these?
$temps['module 1']['inlet'] = 20;
$temps['module 1']['outlet'] = 30;
$temps['module 2']['inlet'] = 25;
$temps['module 2']['outlet'] = 35;
$temps['module 2']['asic-4'] = 50;
You will then use these arrays to generate your graphs?
As long as you had the labels in one array, and the temp values in another, and the order of labels and temps are identical in each array... then this is how you would do it:
// Split Names into Groups
$temps = array(20,25,50,35,30);
$labels = array("module 1 inlet temperature", "module 2 inlet temperature", "module 2 asic-4 temperature", "module 2 outlet temperature", "module 1 outlet temperature");
// Combine Lables to Values (Labels and Values must be in the same positions)
$data = array_combine($labels, $temps);
$temps = array();
foreach ($data as $label => $temp) {
$words = preg_split('/\s/i', $label);
// Combine first two pieces of label for component name
$component = $words[0] . ' ' . $words[1];
// Sensor name is on it's own
$sensor = $words[2];
// Save Results
$temps[$component][$sensor] = $temp;
}
// Print out results for debug purposes
echo '<pre>';
var_dump($temps);
echo '</pre>';
exit();
Once you have the $temp
array, you can use foreach
loops to run through each module and sensor and print out the values for your graphs, or only show certain modules, or certain sensors etc.
Even if it isn't exactely what you're after, hopefully it'll give you some ideas and you can tweak it to suit.