I am having my data in xml. And I want to traverse it. When I print var_dump($video_xml->playlist->video->labels->label) the output is
object(SimpleXMLElement)#41 (4) {
["@attributes"]=>
array(11) {
["id"]=>
string(1) "0"
["start"]=>
string(1) "0"
["end"]=>
string(17) "8.639527777777777"
["pos"]=>
string(12) "124,66,95,45"
["marker"]=>
string(5) "false"
["href"]=>
string(0) ""
["bold"]=>
string(5) "false"
["italic"]=>
string(5) "false"
["color"]=>
string(17) "rgb(62, 201, 106)"
["face"]=>
string(7) "Verdana"
["size"]=>
string(2) "24"
}
[0]=>
string(8) "Label1fg"
[1]=>
string(6) "Label0"
[2]=>
string(6) "Label0"
}
however when I print each object in a foreach loop it gives
object(SimpleXMLElement)#56 (1) {
["@attributes"]=>
array(11) {
["id"]=>
string(1) "0"
["start"]=>
string(1) "0"
["end"]=>
string(17) "8.639527777777777"
["pos"]=>
string(12) "124,66,95,45"
["marker"]=>
string(5) "false"
["href"]=>
string(0) ""
["bold"]=>
string(5) "false"
["italic"]=>
string(5) "false"
["color"]=>
string(17) "rgb(62, 201, 106)"
["face"]=>
string(7) "Verdana"
["size"]=>
string(2) "24"
}
}
I want to print object value like Label0. How can I get it. I am using following code to print label
foreach($video_xml->playlist->video->labels->label as $label){
var_dump($label);
}
and I am expecting output as: string(8) "Label1fg" string(6) "Label0" string(6) "Label0"