[ create a new paste ] login | about

Link: http://codepad.org/SflQ2MzO    [ raw code | output | fork ]

PHP, pasted on Jun 20:
<?php

$all_incidents[]["incident_date"]="02-02-2012";
$all_incidents[]["incident_date"]="02-03-2012";
$all_incidents[]["incident_date"]="02-01-2012";

    $months=array(1=>"Jan",2=>"Feb",3=>'Mar',4=>'Apr',5=>'May',6=>'Jun',7=>'Jul',8=>'Aug',9=>'Sep',10=>'Oct',11=>'Nov',12=>'Dec'); 
    
    $months_are = array();
    foreach($all_incidents as $key => $value)
    {
        $date_bits = explode('-', $value['incident_date']);
        $incidentMonth=intval($date_bits[1]); 
        if($incidentMonth>0)
        {
            $incidents[$incidentMonth]++;
        }         
    }

    ksort($incidents);
    foreach($incidents as $m=>$number)
    {
     echo "Month:".$months[$m]." , Incidents:".$number."<br>";
    }
?>


Output:
1
Month:Jan , Incidents:1<br>Month:Feb , Incidents:1<br>Month:Mar , Incidents:1<br>


Create a new paste based on this one


Comments: