Comment detail
与えられた文字列でピラミッド (Nested Flatten)ちょっと修正。 trim取ったり、substrの引数取ったり。
1 2 3 4 5 6 7 8 | <?php
function pyramid($str){
for($i=$n=strlen($str); $i>=0; $i--, $n=strlen($str)*2-$i+1)
printf("% {$n}s\n", join(" ", preg_split("//", substr($str, $i))));
}
pyramid("abracadabra");
?>
|




hirataka
#2626()
[
PHP
]
Rating0/0=0.00
Rating0/0=0.00-0+
1 reply [ reply ]