How Can I Display Star Triangle Patterns Using PHP

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

Using php we can print star triangle patterns and also diamond shape .So today we discuss how do it.

How Can I Display Star Patterns Patterns Using PHP

Complete Code For Displaying Star Triangle Patterns Using PHP.

<!DOCTYPE html>
<html>
<head>
    <title>How Can I Display Star Triangle Patterns 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;">Star Triangle Patterns Using PHP</h1>
    </div>
    <div class="well">

        <?php
        echo "<h3>First pattern</h3>";
        for($i=0; $i<5; $i++){
            for($j=5; $j>$i; $j--){
                echo '*';
            }

            echo "<br>";
        }
        echo "<h3>Second pattern</h3>";

        for($i=0; $i<5; $i++){
            for($j=0; $j<=$i; $j++){
                echo  '*';
            }
            echo "<br>";
        }
        echo "<h3>Third pattern</h3>";
        for($i=0;$i<=5;$i++){
            for($k=5;$k>=$i;$k--){
                echo "  ";
            }
            for($j=1;$j<=$i;$j++){
                echo "*  ";
            }
            echo "<br>";
        }
        for($i=4;$i>=1;$i--){
            for($k=5;$k>=$i;$k--){
                echo "  ";
            }
            for($j=1;$j<=$i;$j++){
                echo "*  ";
            }
            echo "<br>";
        }
        echo "<h3>Fourth pattern</h3>";
        for ($i=1; $i<=5; $i++)
        {
            for ($j=1; $j<=5; $j++)
            {
                echo '* ';
            }
            echo "</br>";
        }
        ?>
    </div>
</div>
</body>
</html>

Related Post