I found a question on google like this :
When given the input : 4, 7, 3, 6, 7
The output like this :
81 40 41 21 19 22 11 10 9 13 4 7
0) { foreach ($input as $k=>$v) { if (isset($input[$k+1])) $line[] = $v + $input[$k+1]; } $return = implode(' ', $input); rollup($line); } if (!empty($return)) echo $return . ''; } ?>