1

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 ? . . . 
2

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. How can i echo all titles ?
@JBEnergy Loop with foreach over $entries.
I just saw your edit. Is there a way to use the echo $entries[0]->title; and show all the titles. With a loop maybe ?
Haha what a timing! Thank you alex!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.