php 출력 중공 다이아몬드:
<code><span>$a</span>=<span>5</span>;<span>/*控制循环行数*/</span><span>for</span>(<span>$i</span>=<span>1</span>;<span>$i</span>$a;<span>$i</span>++){ <span>for</span>(<span>$b</span>=<span>1</span>;<span>$b</span>$a-<span>$i</span>;<span>$b</span>++){ <span>echo</span><span>" "</span>; } <span>for</span>(<span>$c</span>=<span>1</span>;<span>$c</span>$i-<span>1</span>)*<span>2</span>+<span>1</span>;<span>$c</span>++){ <span>if</span>(<span>$c</span>==<span>1</span>||<span>$c</span>==(<span>$i</span>-<span>1</span>)*<span>2</span>+<span>1</span>){ <span>echo</span><span>"*"</span>; }<span>else</span>{ <span>echo</span><span>" "</span>; } } <span>echo</span><span>"<br>"</span>; } <span>for</span>(<span>$i</span>=<span>$a</span>-<span>1</span>;<span>$i</span>>=<span>1</span>;<span>$i</span>--){ <span>for</span>(<span>$b</span>=<span>1</span>;<span>$b</span>$a-<span>$i</span>;<span>$b</span>++){ <span>echo</span><span>" "</span>; } <span>for</span>(<span>$c</span>=<span>1</span>;<span>$c</span>$i-<span>1</span>)*<span>2</span>+<span>1</span>;<span>$c</span>++){ <span>if</span>(<span>$c</span>==<span>1</span>||<span>$c</span>==(<span>$i</span>-<span>1</span>)*<span>2</span>+<span>1</span>){ <span>echo</span><span>"*"</span>; }<span>else</span>{ <span>echo</span><span>" "</span>; } } <span>echo</span><span>"<br>"</span>; }</code>
출력 결과:
').addClass('pre-numbering'). 숨다(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });위 내용은 PHP 내용을 포함하여 PHP에서의 중공 다이아몬드 출력을 소개한 내용이 PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.