Home >Backend Development >PHP Tutorial >循环有关问题求大神解答 小弟我的QQ是2509577255

循环有关问题求大神解答 小弟我的QQ是2509577255

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:11:34896browse

循环问题求大神解答 我的QQ是2509577255

for($h=mt_rand(3, 9);$h-1>=0;$h--){
for ($z=$h;$z-1>=0;$z--){
echo "0";
}
/*
 * 这里我想写一个循环第一行输出1个* 星号
 * 第二行输出三个 第三行输出五个 第四行输出七个    也就是2n-1个  有n行的话
 * 我在上面随机产生了  3-9行 
 * 这个循环应该怎么写呢?
 */

echo "
";
}
------解决思路----------------------

其实我不知道要干啥   难道是下面的输出?

<?php<br /><br />$rand = mt_rand(3,9);<br /><br />for($h=$rand;$h>0;$h--){<br />    echo str_pad('0',$h,'0').str_pad('*',2*($rand-$h)+1,'*');<br />    echo "<br/>";<br />}


000000*<br />00000***<br />0000*****<br />000*******<br />00*********<br />0***********

Statement:
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