Printing an Array out
I have an array which is returned from the function $site->latestBookmarks() and it contains the following:
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 $latest开发者_运维问答bookmarks['title'];
}
?>
</body>
</html>
At the moment is just keeps on looping.
foreach($site->latestBookmarks() as $bookmark) {
echo $bookmark['title'];
}
精彩评论