Home >Backend Development >PHP Tutorial >如何用日期(UNIX timestamp)分隔文章列表?

如何用日期(UNIX timestamp)分隔文章列表?

WBOY
WBOYOriginal
2016-06-23 13:43:16838browse

news_table
id (PK)
title
time (INT 10) (UNIX timestamp 格式)
content

如何做到....以下的格式

2014-12-16 的新闻...
标题标题标题标题标题

标题标题标题标题标题

标题标题标题标题标题

=================================
2014-12-15 的新闻...
标题标题标题标题标题

标题标题标题标题标题
==================================

2014-12-09  的新闻...
标题标题标题标题标题

标题标题标题标题标题



我有用SMARTY应该在SMAERT做还是在php做分割?

请提供点思路


回复讨论(解决方案)

通过php处理 生成需要格式的字符串,通过smarty展示

现在处理后的数组:
Array
(
    [0] => Array
        (
            [id] => 10
            [title] => title....title
            [create_time] => 1418745763
            [date] => 2014-12-17
        )

    [1] => Array
        (
            [id] => 9
            [title] => title....title
            [create_time] => 1418745155
            [date] => 2014-12-16
        )

    [2] => Array
        (
            [id] => 8
            [title] => abcabcabc
            [create_time] => 1418744953
            [date] => 2014-12-16
        )

    [3] => Array
        (
            [id] => 7
            [title] => bbbbbb
            [create_time] => 1416772786
            [date] => 2014-11-24
        )

    [4] => Array
        (
            [id] => 1
            [title] => aaaaaaa
            [create_time] => 1415879638
            [date] => 2014-11-13
        )
)


如何把[date] 做成一个2维数组,然后在smarty 二层循环?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn