All pastes #425492 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-05 14:49 UTC
rendered paste body
function recsum($a, $index)
{
	if($index>0)
	{
		$total=$a[$index]+recsum($a,$index-1);
	}
	else
	{
		$total=$a[$index];
	}
	return $total;
}

$array=array(1,2,3,4,5);
$sum=recsum($array,4);
echo $sum;