由周

2012-05-15 47 views
1

排序陣列中的信息我有日期的像由周

array 
1 => string '2012-02-27' (length=10) 
2 => string '2012-03-02' (length=10) 
59 => string '2012-03-05' (length=10) 

等陣列。這些日期代表人們申請某些東西的日子。例如,在2月27日,3人申請,並在3月1日2.

我想要做的是創建一個表,表示在2012-02-262012-03-03的一週說5人提交申請。左欄的標題爲Weeks,右欄爲# of applications received

我已經在白天設置了桌子,但幾周也會有幫助。我曾看過一篇文章,談論上市周,並嘗試使用,但它沒有奏效。

更具體地說,我的問題是如何獲取日期數組並將它們分解幾周並將該信息放在表中?

+0

1 =>是3 =>可能是嗎? – sivann

+1

a)你需要發佈你的代碼(我看你是新手,所以你得到一些保護嬰兒),b)請讓你的具體問題更清楚,什麼是封路器?請閱讀:[您嘗試過什麼](http://mattgemmell.com/2008/12/08/what-have-you-tried/),然後通過編輯來改善您的問題。 – hakre

+0

不完全。鑰匙是人的身份。 – Brittany

回答

0

你可能想這在PHP中,沒有一個DB。

1) convert dates to epoch (seconds) with strtotime() 
2) sort array by (numeric now) date with asort() 
3) loop through the sorted now array from start date to end date and add the values. 

當然,使用數據庫可以做得更容易。