# PHP program to display number pattern

In this example, we will write a number pattern program in PHP. a pattern like Half Pyramid of Numbers, inverted pyramid, etc

Let us discuss some examples to understand the concept of number patterns program in PHP easily

## Half Pyramid of Numbers

``````
<?php
function pattern1(\$value)
{
\$num = 1;
for (\$i = 0; \$i < \$value; \$i++)
{
for (\$j = 0; \$j <= \$i; \$j++ )
{
echo \$num." ";
}
\$num = \$num + 1;
echo "\n";
}
}
\$value = 7;
pattern1(\$value);
?>
``````

## output

```1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7 ```

## Half Pyramid with Numbers increment

``````
<?php
<?php
function pattern2(\$value)
{
for (\$i = 0; \$i <= \$value; \$i++)
{
for (\$j = 1; \$j <= \$i; \$j++ )
{
echo \$j." ";
}
echo "\n";
}
}
\$value = 7;
pattern2(\$value);
?>
``````

## output

```1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7 ```

## Example 3: Inverted half pyramid of numbers

``````
<?php
function pattern1(\$value)
{
for (\$i = \$value; \$i >= 1; \$i--)
{
for (\$j = 1; \$j <= \$i; \$j++ )
{
echo \$j." ";
}
echo "\n";
}
}
\$value = 7;
pattern1(\$value);
?>
``````

## output

```1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1 ```