Reputation: 37
Please see this code below:
for($i=0;$i<=count($s->channel);$i++){
echo "--->".$ChannelName = $s->channel[$i]->{'display-name'};
$arrChannelName[] = $ChannelName;
}
print_r($arrChannelName);
This return me output as Object instead of an array as:
Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[lang] => dk
)
[0] => DR1 DK
)
)
Anybody please help...!!!
Regards
Upvotes: 0
Views: 59
Reputation: 12417
$arr = array("somearray" => array(6 => 5, 13 => 9, "a" => 42));
echo $arr["somearray"][6]; // 5
Like this , you can read that object array.
Or
You can use stdclass
http://www.phpro.org/examples/Convert-Object-To-Array-With-PHP.html
Upvotes: 0
Reputation: 1738
Actually, you have an array of objects of type SimpleXMLElement. Your array has a length of one and key 0 is mapped to the SimpleXMLElement.
Upvotes: 2