how to get the value of the index
Posted: Wed Oct 25, 2006 9:27 pm
Hi,
I am using simplexml_load_string which gives me an object with one single dimensional array.
SimpleXMLElement Object ( [title] => Forty What? [from] => Joe [to] => Jane [body] => I know thats the answer -- but whats the question? )
Everything looks good, as I wanted to run the for loop and get the values out of the array ....... code below
The result of print_r($v); gives me instead of values following
SimpleXMLElement Object ( [0] => Forty What? ) SimpleXMLElement Object ( [0] => Joe ) SimpleXMLElement Object ( [0] => Jane ) SimpleXMLElement Object ( [0] => I know that's the answer -- but what's the question? )
But i need to retrive only the values like "Joe" "Jan" how could I do that? Thanks
I am using simplexml_load_string which gives me an object with one single dimensional array.
SimpleXMLElement Object ( [title] => Forty What? [from] => Joe [to] => Jane [body] => I know thats the answer -- but whats the question? )
Everything looks good, as I wanted to run the for loop and get the values out of the array ....... code below
Code: Select all
$xmlblock="<document>
<title>Forty What?</title>
<from>Joe</from>
<to>Jane</to>
<body>
I know that's the answer -- but what's the question?
</body>
</document>";
$xmlparsed = simplexml_load_string($xmlblock);
foreach ($xmlparsed as $s => $v)
{
print_r($v);
}SimpleXMLElement Object ( [0] => Forty What? ) SimpleXMLElement Object ( [0] => Joe ) SimpleXMLElement Object ( [0] => Jane ) SimpleXMLElement Object ( [0] => I know that's the answer -- but what's the question? )
But i need to retrive only the values like "Joe" "Jan" how could I do that? Thanks