Splitting an Amount over X days
<p>I have a small script that splits out an amount of revenue over a span of days. I can't seem to wrap my head around allowing for any number of days. Currently I can only get it to work if I hard-set an array of %s for each amount of days, which obviously isn't going to work for large sets of day combinations.</p>

<p>If anyone has an idea as to how to accomplish this, I'd be ever grateful.</p>

<p>My Code:</p>

<pre><code>&lt;?php
//define variables
$ammount = 11320.00;
$start_date = "12/30/2011";
$days = 5;

//setup array of percents
$percent_array = array(3=&gt;array(0 =&gt; 45, 1 =&gt; 30, 2 =&gt; 25), 4=&gt;array(0 =&gt; 40, 1 =&gt; 30, 2 =&gt; 20, 3 =&gt; 10),4=&gt;array(0 =&gt; 35, 1 =&gt; 25, 2 =&gt; 20, 3 =&gt; 10, 4 =&gt; 10));

//handle formatting the date for use in loop
$format = 'D m/d/Y';
$sDate = strtotime($start_date);

if ($usersTS !== false) {
    for ($i = 0; $i &lt; $days; $i++) {
        echo date($format, strtotime('+' . $i . ' day', $sDate));
        echo " : ";
        echo number_format($ammount * ($percent_array[$days][$i] / 100), 2, ".", ",");
        echo "&lt;br /&gt;";
    }
} else {
    echo "No valid date supplied";
};
?&gt;
</code></pre>

<p>Output:</p>

<pre><code>Fri 12/30/2011 : 3,962.00
Sat 12/31/2011 : 2,830.00
Sun 01/01/2012 : 2,264.00
Mon 01/02/2012 : 1,132.00
Tue 01/03/2012 : 1,132.00
</code></pre>
