开发者

Printing an Array out

开发者 https://www.devze.com 2023-03-06 15:36 出处:网络
I have an array which is returned from the function $site->latestBookmarks() and it contains the following:

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'];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消