I'm using PHP 5.4 and getting back array structures like this:
Array
(
[0] => Array
(
[HGS-SUB] => SimpleXMLElement Object
(
[0] => 59.00
)
)
[1] => Array
(
[DOMN-MTH] => SimpleXMLElement Object
(
[0] => 25.00
)
)
)
I can't figure out how to retrieve (for example) the string "HGS-SUB" and the number "59.00" within a foreach loop. Note: HGS-SUB is dynamic data that is not known until runtime, so I can't hardcode it. Here is my foreach:
foreach ($matchingProducts as $key => $value){
EmitObjectDetails($value);
}
Result:
Array
(
[HGS-SUB] => SimpleXMLElement Object
(
[0] => 59.00
)
)
Array
(
[DOMN-MTH] => SimpleXMLElement Object
(
[0] => 25.00
)
)
My desire result for the 1st iteration of the loop is to capture the string "HGS-SUB" and the number "59.00". Similarly, in the 2nd iteration of the loop I want to capture the string "DOMN-MTH" and "25.00".
I have tried all sorts of experiments such as:
- $value[0]
- $value[$key];
- $value->{0}
- $value[0][0]
Nothing works. Please help.