Not being a coder, I'm trying to do the following and loosing my mind trying to do it. I'm sure the answer probably about as basic as they get but I can't seem to find an answer.
Anyways, here goes. Have a multidimensional array:
Array
[module 2] => Array
(
[1] => SimpleXMLElement Object
(
[0] => module 2 EARL outlet temperature
)
[2] => SimpleXMLElement Object
(
[0] => module 2 inlet temperature
)
[15] => SimpleXMLElement Object
(
[0] => module 2 EARL inlet temperature
)
[19] => SimpleXMLElement Object
(
[0] => module 2 outlet temperature
)
)
[module 6] => Array
(
[3] => SimpleXMLElement Object
(
[0] => module 6 EARL inlet temperature
)
[4] => SimpleXMLElement Object
(
[0] => module 6 asic-4 temperature
)
[11] => SimpleXMLElement Object
(
[0] => module 6 RP inlet temperature
)
[24] => SimpleXMLElement Object
(
[0] => module 6 asic-3 temperature
)
[25] => SimpleXMLElement Object
(
[0] => module 6 inlet temperature
)
[26] => SimpleXMLElement Object
(
[0] => module 6 EARL outlet temperature
)
[28] => SimpleXMLElement Object
(
[0] => module 6 outlet temperature
)
[30] => SimpleXMLElement Object
(
[0] => module 6 RP outlet temperature
)
)
What I need is, from each array (module 1, module 2, etc...), return the numeric keys from each of the subarray values. Basically each of the subarray keys corresponds to the key of a another array which contains temperatures to be graphed by rrdtool.
Thanks to someone elses help last night I was able to correctly group the values by "module #" (how I ended up with the array above). But now every time I run through my foreach loops (below) I get the results returned twice.
## Just for testing my foreach loops
foreach ($groupedmods as $modgroupname => $sensorname) {
foreach ($sensorname as $dsindex => $sensor) {
if($dsindex != 0) {
file_put_contents('/usr/local/nagiosxi/var/php.log', print_r($dsindex, true). "\n", FILE_APPEND);
}
}
}
## Draw some graphs
#foreach ($groupedtemps as $modgroupname ) {
# $ds_name[$dcnt] = "Module Temps Test";
# $opt[$dcnt] = "--vertical-label \"Temp\" --title \"Module Temps Test \" ";
#
# foreach ($modgroupname as $dsindex ) {
# if($dsindex != 0) {
#file_put_contents('/usr/local/nagiosxi/var/php.log', print_r($dsindex, true ). "\n", FILE_APPEND);
# $def[$dcnt] = "DEF:var$dsindex=$rrdfile:$DS[$dsindex]:AVERAGE " ;
# $def[$dcnt] .= "LINE2:var$dsindex#F00808:$sensor\"\" " ;
# }
# }
#}
outputs the list of indexes I need two times:
1
2
15
19
3
4
11
24
25
26
28
30
5
16
17
20
21
22
23
29
6
8
7
18
9
31
10
27
12
35
13
32
14
33
34
1
2
15
19
3
4
11
24
25
26
28
30
5
16
17
20
21
22
23
29
6
8
7
18
9
31
10
27
12
35
13
32
14
33
34