Multidimensional Array Confusion
Posted: Sun Jun 20, 2010 4:54 pm
GAH! These things still confuse me.
I have a 2 dimensional associative array that I pull from my database. From the debts table, I pull (balance, apr, payment, type). I need to produce a payment schedule. During the loops I do of course need to subtract the payment from the balance and add accrued interest. The added problem is that there is an outside variable called $extra that needs to only be added to the first debt in the array that does not have a balance of 0. The goal of course is to pay down each debt until it gets to 0. $extra get applied to each debt when the one above it gets paid off.
I could do this with a series of database reads and writes but that's obviously a VERY inefficient way of doing things. I just can't get a grip on how to loop through a multidimensional array.
I will continue to poke away at this while I wait for your answer.
Thanks
I have a 2 dimensional associative array that I pull from my database. From the debts table, I pull (balance, apr, payment, type). I need to produce a payment schedule. During the loops I do of course need to subtract the payment from the balance and add accrued interest. The added problem is that there is an outside variable called $extra that needs to only be added to the first debt in the array that does not have a balance of 0. The goal of course is to pay down each debt until it gets to 0. $extra get applied to each debt when the one above it gets paid off.
I could do this with a series of database reads and writes but that's obviously a VERY inefficient way of doing things. I just can't get a grip on how to loop through a multidimensional array.
I will continue to poke away at this while I wait for your answer.
Thanks