PHP:每月显示条目

时间:2011-07-24 14:35:25

标签: php

<?php
        while($show = $grabAlbums->fetch() ){
            $date_headers_array[date('m', $show["date"])][date('d', $show["date"])][] = $show;
        }

foreach ($date_headers_array as $month => $v1) {
    foreach ($v1 as $day => $v2) {
    ?>
<h3 class="EventlistHeader" style="margin-bottom: 4px;">
    <?php 
    echo htmlentities(ucfirst(strftime("%A", $v2[0]['date'])))." ";
    echo $day.". ".strftime('%B', $v2[0]['date']); 
    ?>
</h3>
<?php
foreach ($v2 as $album) {
echo $album["content"] "<br>";
}
?>

这是$ show [“date”]

中存在的每一天的h3标题

我要做的是每月显示标题。

它现在显示如下:

**Tuesday 12 july:**
content
**Wednesday 13 july:**
content
**Thursday 28 july:**
content

我希望它显示如下:

**July**
12th, content
13th, content
28th, content

**是h3标题

我该怎么做?

1 个答案:

答案 0 :(得分:1)

foreach ($date_headers_array as $month => $v1) {
    echo "<h3>$month</h3>";
    foreach ($v1 as $day => $v2) {
       echo "$day, ";
    ...

我将用jan-dec留下变化的1-12,并将st,nd,th添加到你