Hi I have following simple xml object:
[ad] => Array
(
[0] => SimpleXMLElement Object
(
[title] => <b>Title: Mysql 1</b>
[abstract] => Abstract: Mysql 1
[url] => www.Mysql.com
[rurl] => http://sample/xtrack.php?rurldata=yes
[iurl] => http://sample.com/
[bid] => 0.0880
)
[1] => SimpleXMLElement Object
(
[title] => <b>Title: Mysql 2</b>
[abstract] => Abstract: Mysql 2
[url] => www.Mysql.com
[rurl] => http://sample/xtrack.php?rurldata=yes
[iurl] => http://sample.com/
[bid] => 0.1980
)
)
I want to create an array from this. I am trying in foreach like this
foreach($xmlString->ad as $key){
foreach($key as $key2 => $val2){
$adData[$counter][$key2] = $val2;
}
$counter++;
}
But I get a structure like this:
Array
(
[0] => Array
(
[title] => SimpleXMLElement Object
(
[0] => <b>Title: Mysql 1</b>
)
[abstract] => SimpleXMLElement Object
(
[0] => Abstract: Mysql 1
)
[url] => SimpleXMLElement Object
(
[0] => www.Mysql.com
)
[rurl] => SimpleXMLElement Object
(
[0] => http://sample/xtrack.php?rurldata=yes
)
[iurl] => SimpleXMLElement Object
(
[0] => http://sample.com/
)
[bid] => SimpleXMLElement Object
(
[0] => 0.0880
)
)
.
.
.So on
now I know that $key2 is an object. How can i retrieve only tag name of that ? How to go about this?
This bellow example may helps you..
XML File: student.xml
PHP Code: