开发者

PHP Looping based on date

ok so i have this array of a开发者_StackOverflow中文版bout 151 elements and there is a date field as one of the elements. The array is a two week range. I want to count how many elements are in the first week and how any are in the second week. Here is my example array.

[0] => Array
    (
        [0] => 4d50
        [date] => 07-10-2010
        [telephone] => something
        [Sno] => 1
     )

[1] => Array
    (
        [0] => 4g50
        [date] => 07-03-2010
        [telephone] => something
        [Sno] => 1
    )

[2] => Array
    (
        [0] => 4s50
        [date] => 06-29-2010
        [telephone] => something
        [Sno] => 1


function getweek($a){
   //altered code., m-d-Y is no a format strtotime likes):
   return  DateTime::createFromFormat('m-d-Y',$a['date'])->format('W');
}
var_dump(array_count_values(array_map('getweek',$inputarray)));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜