php在日期列上排序多维数组

时间:2014-01-18 01:38:58

标签: php multidimensional-array

我有一个数组$ dataStoreForTableImport以下列方式设置。

$dataStoreForTableImport['title']
$dataStoreForTableImport['content']
$dataStoreForTableImport['date']
$dataStoreForTableImport['link']
$dataStoreForTableImport['username']
$dataStoreForTableImport['website']

它包含以下数据

Array
(
[0] => Array
    (
        [title] => Quote from Tony Blair
        [content] => ... from beating it I'm afraid." (Tony Blair, Sky News) He had every opportunity to put religion in its ...
        [articledate] => 28/09/2013
        [link] => http://boards.fool.co.uk/message.asp?source=isesitlnk0000001&mid=12890951
        [Username] => Michael Dray
        [website] => The Motley Fool
    )

[1] => Array
    (
        [title] => Re: The Tony Blair Show
        [content] => ... I am irritated that he got such an easy ride; Why? Because he is not to your political liking? He was a witness; he was not on trial and he spoke under oath. What did you expect Jay to ask him? I had dealings with a QC a few years ago. He was as ...
        [articledate] => 28/05/2012
        [link] => http://boards.fool.co.uk/message.asp?source=isesitlnk0000001&mid=12564154
        [Username] => Michael Dray
        [website] => The Motley Fool
    )

[2] => Array
    (
        [title] => Re: The Tony Blair Show
        [content] => ... If your doubts about Jay's competence/bias were shared I'm sure it would have been debated ad nauseam on Radio 4. Eh - are you serious? I'm a Radio 4 fan - but thats despite its hatred of all things right of centre, not becuase of. ...
        [articledate] => 28/05/2012
        [link] => http://boards.fool.co.uk/message.asp?source=isesitlnk0000001&mid=12564167
        [Username] => Michael Dray
        [website] => The Motley Fool
    )

[3] => Array
    (
        [title] => Re: The Tony Blair Show
        [content] => ... Maybe Tony should have brought Cherie with him - remember Rupert Murdoch and the reaction of Wendi Deng to the custard pie incident. IMHO Cherie is every bit as intimidating:-) Wendi Deng did not eject the pie flinger, she intervened when he acted. Use of an angled bat to deflect criticism from ...
        [articledate] => 30/05/2012
        [link] => http://boards.fool.co.uk/message.asp?source=isesitlnk0000001&mid=12565346
        [Username] => Michael Dray
        [website] => The Motley Fool
    )

[4] => Array
    (
        [title] => Re: The Tony Blair Show
        [content] => ... What did surprise me was the fact that he had his own personal bodyguards in the hearing with him. Although, given the level of security that allowed that protester to break into the hearing, maybe he had a point! Eh? He is clearly at risk of terror ...
        [articledate] => 28/05/2012
        [link] => http://boards.fool.co.uk/message.asp?source=isesitlnk0000001&mid=12564500
        [Username] => Michael Dray
        [website] => The Motley Fool
    )

如果articleDate在给定日期之前,我希望能够从此数组中删除行。

我已经尝试了所有东西,但似乎没有用。我甚至无法按日期对其进行正确排序?

日期格式为 - 2007年2月10日

我用过

$sortDate = date('d/m/Y', strtotime($sortDate));

将其格式化为上面数组中显示的格式。

有人可以帮忙吗?

由于

麦克

1 个答案:

答案 0 :(得分:0)

对数据库后端中的行进行过滤和排序。这将改善您的应用程序的性能。使用WHERE子句按日期过滤,使用ORDER BY子句在SQL查询中按日期排序。