Echo array values ​​in PHP

How can I echo, for example, the header of the next array? (records). Using print_r, I get this (I publish only part of it). I would like to create a variable for each element that I want to echo, this will help me make some changes on it before showing the result.

Thank 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 ? . . . 
+1
source share
1 answer

How can I echo, for example, the header of the next array?

Trim the first element of the array, and then access the title property ...

 echo $entries[0]->title; 

I would like to create a variable for each element that I want echo

You can do it manually ...

 $title = $entries[0]->title; 

Or do it automatically with extract() ...

 extract((array) $entries[0], EXTR_SKIP); 

Be careful with extract() . It will not overwrite existing variables with the EXTR_SKIP flag, so keep that in mind.

+1
source

All Articles