Home > Backend Development > PHP Tutorial > How to output an isosceles triangle in PHP, PHP outputs an isosceles triangle_PHP tutorial

How to output an isosceles triangle in PHP, PHP outputs an isosceles triangle_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 09:54:15
Original
2392 people have browsed it

How to output an isosceles triangle in PHP, and how to output an isosceles triangle in php

The example in this article describes how to output an isosceles triangle in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

function isosceles($line,$sing){
  $tab ='=';  
  for($i=1;$i < $line+1;$i++){
    $blank = print_blank($i,$line,$tab);
    $code = print_code($i,$sing);
    echo $blank.$code.$blank."<br>";
  }
}
function print_blank($num,$line,$tab){
  $blank ='';
  for($i=$num;$i<$line;$i++){
    $blank.=$tab;
  }
  return $blank;
}
function print_code($num,$sing){
  $code ='';
  for($i=0;$i<(2*($num-1)+1);$i++){
    $code.=$sing;
  }
  return $code;
}
$line = 5;
$sing = "*";
isosceles($line,$sing);
Copy after login

The running results are as follows:

====*====
===****===
==*****==
=*******=
*********

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/998559.htmlTechArticleHow to output an isosceles triangle in PHP, how to output an isosceles triangle in php. This article explains how to output an isosceles triangle in PHP. method. Share it with everyone for your reference. The specific implementation methods are as follows...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template