Reputation: 147
How can I echo for example the title of the following array? (entries). Using print_r I get this ( I post only a part of it). I would like to create a variable for each item I want to echo, this will help me on doing some modifications on it before showing the result.
Thank you stackoverflow!
Array
(
[0] => SimpleXMLElement Object
(
[guid] => tag:blogger.com,1999:blog-8508477708802179245.post-7592005355313594438
[pubDate] => Sun, 29 May 2011 12:05:00 +0000
[category] => Thoughts
[title] => Should I go for it ?
.
.
.
Upvotes: 1
Views: 251
Reputation: 490597
How can I echo for example the title of the following array?
Subscript the first array element, and then access its title
property...
echo $entries[0]->title;
I would like to create a variable for each item I want to
echo
You could do this manually...
$title = $entries[0]->title;
Or do it automatically with extract()
...
extract((array) $entries[0], EXTR_SKIP);
Be careful with extract()
. It won't overwrite existing variables with the EXTR_SKIP
flag, so keep that in mind.
Upvotes: 1