简体   繁体   English

PHP:每月显示条目

[英]PHP: show entrys per month

<?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>";
}
?>

This is making a h3 header for each day that exists in $show["date"] 这将为$ show [“ date”]中存在的每一天制作一个h3标头

What i am looking for to do is to show header per month instead. 我想要做的是改为每月显示标题。

It shows like this now: 现在显示如下:

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

I want it to show like this: 我希望它显示如下:

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

** is the h3 header **是h3标头

how can i do this? 我怎样才能做到这一点?

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

I will leave the changing 1-12 with jan-dec, and adding the st,nd,th to you 我将把jan-dec更改为1-12,然​​后将st,nd,th添加到您的计算机中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM