Complete Code For Printing Numeric Triangle Pattern Using PHP.
<!DOCTYPE html>
<html>
<head>
<title>How Can I Print Numeric Triangle Pattern Using PHP</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
body {
background: black;
}
</style>
<body>
<body>
<div class="container">
<br/><br/>
<div class="text-center">
<h1 id="color" style="color: white;">Print Numeric Triangle Pattern Using PHP</h1>
</div>
<div class="well">
<?php
echo "<h3>First pattern</h3>";
$num1 = 1;
for($i=0; $i<5; $i++){
for($j=5; $j>$i; $j--){
echo $num1;
}
$num1 = $num1 + 1;
echo "<br>";
}
echo "<h3>Second pattern</h3>";
$num2 = 1;
for($i=0; $i<5; $i++){
for($j=0; $j<=$i; $j++){
echo $num2;
}
$num2 = $num2 + 1;
echo "<br>";
}
echo "<h3>Third pattern</h3>";
$num = 1;
for ($i = 0; $i < 5; $i++)
{
for ($j = 0; $j <= $i; $j++ )
{
echo $num." ";
$num = $num + 1;
}
echo "<br>";
}
?>
</div>
</div>
</body>
</html>