I found the Inverted Pyramid that I wrote when I was learning PHP a few months ago. It took me more than an hour to understand it. I was still depressed about how I wrote it back then. It turned out to be regular. Now I have refined the code and written it down. Code is something I’m really afraid of forgetting -_-!!!
Code:
function a($n){
$p = ($n+1) /2; use using using ‐ ’ ’ s ‑ ‐ ‐ ‐ ‐ calculated for the middle line number
to 2*$i-1; //Upper half: number of * signs in each line
$sp = ($n-$m)/2; Number
for ($ j = 1; $ j & lt; = $ sp; $ j ++) {echo "& nbsp;" ";} // space
for ($ j = 1; $ j & lt; = $ j ++) {echo "*";} } Else {
if ($ i == $ p) {// Traversing the middle line: the number in the middle is just equal to the number of rows
for ($ j = 1; $ j & lt; = $ n; $ j ++) {echo "" "{echo" " "
/*Number of numbers (regular-symmetrical)
echo " ";} for($j=1;$j< ;=$sp;$j++){echo " ";}
}
}
a(9);
?>
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces the PHP loop traversal of the inverted pyramid, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.