Pyramid of stars in PHP

Write a program to generate pyramid of stars.

This is the most commonly asked question to beginners. Though this seems to be very complex during my school days, but not.

Program to generate/draw pyramid of stars/asterisks in php

<?php
echo '<pre>';
$horizontal = 10;
$vertical = 10;
while ($vertical--)
    echo str_repeat(' ', $vertical) . str_repeat('* ', $horizontal - $vertical) . "\n";
echo '</pre>';
?>
'Coz sharing is caring

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.