I do not know whether it is a character set problem or an algorithm problem for ($ r = 1; $ r & lt; = $ rows; $ r ++) {& nbsp; & nbsp; for ($ n = $ rows; $ n & gt; $ r; $ n --) {echo & nbsp; "& amp; nbsp" ;}& nbsp; & nbsp; for ($ m = 0; $ I do not know whether it is a problem with character sets or algorithms.
for($r=1;$r<=$rows;$r++){
for($n=$rows;$n>$r;$n--){
echo " ";
}
for($m=0;$m<$r ;$m++){
echo "*";
}
echo "
";
}
To achieve
But now it becomes
Is it my algorithm problem? I open in IE browser, the default GB2312 character set is displayed correctly, UTF-8 is displayed is wrong.
Is this the case only when the character set problem occurs? how can this problem be solved? Thank you !~
------ Solution --------------------
Of course not an algorithm problem!
Originally, this type of question was tested in text mode. you need to put it in html.
$ Rows = 12;
Echo'';
for($r=1;$r<=$rows;$r++){
for($n=$rows;$n>$r;$n--){
echo " ";
}
for($m=0;$m<$r ;$m++){
echo "*";
}
echo PHP_EOL;
}
In this way, no deformation will occur.