开发者

PHP: show entrys per month

开发者 https://www.devze.com 2023-03-22 08:28 出处:网络
<?php while($show = $grabAlbums->fetch() ){ $date_headers_array[date(\'m\', $show[\"date\"])][date(\'d\', $show[\"date\"])][] = $show;
<?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) {
    ?>
&开发者_如何学编程lt;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"]

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

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

0

精彩评论

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