Echo在PHP数组的值 [英] Echo the values of an array in PHP
问题描述
我如何呼应例如下面的数组的标题? (项)。使用的print_r我得到这个(我只张贴它的一部分)。
我想创造我想呼应的每个项目的变量,这将帮助我在显示结果之前,做一些关于它的修改。
感谢您的StackOverflow!
阵列
(
[0] => SimpleXMLElement对象
(
[GUID] =>标签:blogger.com,1999:博客 - 8508477708802179245.post-7592005355313594438
[pubdate的] =>太阳,2011 12:05:00 +0000 5月29日
【类别】= GT;思考
[标题] =>我应该去吗?
。
。
。
我如何呼应例如下面的数组的标题?
块引用>下标第一个数组元素,然后访问它的
标题
属性...回声$项[0] - >称号;
我要创造我想每个项目一个变量
回声
块引用>您可以手动执行此操作...
$标题= $条目[0] - >称号;
,使用
自动完成提取物()
...提取物((阵列)$项[0],EXTR_SKIP);
要小心
提取物()
。它不会覆盖与EXTR_SKIP
标志现有的变量,所以记住这一点。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 ? . . .
解决方案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 theEXTR_SKIP
flag, so keep that in mind.这篇关于Echo在PHP数组的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!