[英]Printing an Array out
I have an array which is returned from the function $site->latestBookmarks() and it contains the following: 我有一个从$ site-> latestBookmarks()函数返回的数组,它包含以下内容:
Array ( [0] => Array ( [url] => http://support.apple.com/kb/HT1343 [title] => Mac OS X Keyboard Shortcuts ) [1] => Array ( [url] => http://stuffkit.com/30-stunning-mixed-hq-wallpapers.htm [title] => 30 Stunning Mixed HQ Wallpapers ) )
I am trying to print the title of both of the items. 我正在尝试打印两个项目的标题。
<?php
// index.php
include 'classes/Site.class.php';
$site = new Site();
print_r($site->latestBookmarks());
?>
<html>
<head>
<title>Index</title>
</head>
<body>
<h1>Latest Bookmarks</h1>
<?php
while ($latestbookmarks = $site->latestBookmarks()) {
echo $latestbookmarks['title'];
}
?>
</body>
</html>
At the moment is just keeps on looping. 此刻只是不断循环。
foreach($site->latestBookmarks() as $bookmark) {
echo $bookmark['title'];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.