Home > Backend Development > PHP Tutorial > How to use the for statement to output triangles in php, phpfor statement triangle_PHP tutorial

How to use the for statement to output triangles in php, phpfor statement triangle_PHP tutorial

WBOY
Release: 2016-07-13 09:51:26
Original
2756 people have browsed it

php uses the for statement to output triangles, phpfor statement triangles

This article describes the example of php using the for statement to output triangles. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php
 //phpinfo();
  function Dis($num)
  {
    if($num<=0)
    return;
    $tmpRow=0;
    for($i=1;$i<=$num;$i++)
    {
      $tmpRow=$i<=$num/2 &#63; $i:$num-$i+1;
      echo str_repeat('*',2*$tmpRow-1).'<br />';
    }
  }
  Dis(19);
&#63;>

Copy after login

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1013714.htmlTechArticleHow to use the for statement to output a triangle in php, phpfor statement triangle This article describes how to use the for statement to output a triangle in php . Share it with everyone for your reference. Specific implementation method...
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template