Maybe I misunderstood what you're trying to do. It looks to me like this function takes an array and generates some html, which is stored in the local variable $basket. The function returns $basket. What I thought you also wanted to do was calculate a subtotal for the values in the array. Is that right?
If that's right, then I believe my first post is correct. About the error on line 15: make sure the function definition and all calls to the function have the same # of args.
The definition is like this:
function show_array($arr, &$sub_total, $i=0)
Calls should be like this:
$b = show_array($my_arr, $sub_total, $x)
Whether or not you should keep a running subtotal is up to you. You would have to remember to modify it any time the user modifies his shopping cart. If it were me, I would want to save the subtotal calculation to the very end, for simplicity.
You could also make a seperate function for calculating the subtotal:
function calc_subtotal($arr) {
if(!is_array($arr)) return $arr; // nothing to do, $arr is not an array;
foreach($arr as $key => $val){
if(!is_array($val)){
if ($key == "t_price") {
$sub_total += $val;
}
} else {
$sub_total += calc_subtotal ($val); // walk innervalue recursively
}
}
return $sub_total;
}
Then you could take all the subtotal stuff out of show_array().