How to create a triangle in php, This is a very common question for beginner and intermediate-level programmers. I will share a script that will generate a triangle using PHP.
This is a very common type of question in interviews. The programming languages can vary but the question will same as how to generate a triangle.
We’ll cover the following topics here:
The Below php code will use to create a right angle from 1- 9.
<?php for ($i=0; $i<=9; $i++) { for($j=1; $j<=$i; $j++) { echo $i ." "; } echo "\n"; }
Output:
The below code are creating right angle using star(*
).
<?php for($i=0;$i<10;$i++){ for($j=1;$j<$i;$j++){ echo "* "; } echo "\n"; }
Output:
The Below PHP code will use to create a Triangle from 1- 10.
for ($i=9; $i>=1; $i--) { for($j=1; $j<=$i; $j++) { echo ' '; } $j--; for ($k=1; $k<=(10-$j); $k++) { echo " # "; } echo "\n"; }
Output:
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More
View Comments
would u please help me in doins so
for which?
Ok,
can u plz ping me on phpflowcom facebook page, so that i can share solution.