Skip to content

Instantly share code, notes, and snippets.

@shadowhand
Forked from anonymous/snippet.html
Created December 7, 2009 05:37
Show Gist options
  • Save shadowhand/250646 to your computer and use it in GitHub Desktop.
Save shadowhand/250646 to your computer and use it in GitHub Desktop.
<?php
$files = glob('/Users/wgilk/Desktop/calls/*.csv');
$data = array();
foreach ($files as $file)
{
$csv = fopen($file, 'r');
$cols = fgetcsv($csv);
while ($line = fgetcsv($csv))
{
$line = array_combine($cols, $line);
$date = strtotime($line['Date']);
$set =& $data[date('n', $date)][date('j', $date)];
$set += $line['Minutes'];
}
}
array_shift($data);
array_pop($data);
echo '<dl>';
foreach ($data as $month => $days)
{
echo '<dt>Days: ', $d = count($days), ' – Minutes: ', $m = array_sum($days),'</dt>';
echo "<dd>$1/day + $0.10/min: $", number_format($d + ($m * 0.10), 2), '</dd>';
echo "<dd>$0.25/min: $", number_format($m * 0.25, 2), '</dd>';
echo "<dd>$3/day: $", number_format($d * 3, 2), '</dd>';
}
echo '</dl>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment