# PHP program to print continuous numbers in the form of triangle

PHPServer Side ProgrammingProgramming

To print continuous numbers in the form of triangle in PHP, the code is as follows −

## Elements

Live Demo

<?php
function continuous_pattern($val) {$num = 1;
for ($m = 0;$m < $val;$m++)
{
for ($n = 0;$n <= $m;$n++ )
{
echo $num." ";$num = $num + 1; } echo "\n"; } }$val = 4;
continuous_pattern(\$val);
?>

## Output

1
2 3
4 5 6
7 8 9 10

This is similar to generating a star or a number pattern, the only difference being, continuous numbers are generated instead of stars or repeated numbers. The function ‘continuous_pattern’ is defined that takes the limit as a parameter. The limit value is iterated over and the number is printed and increment. The relevant line breaks are also generated in between. The function is called by passing this limit value and the relevant output is generated on the console.

Updated on 02-Jul-2020 06:35:25