<?php
$num=10;
$thestr="a";
for ( $i=1; $i<=$num-1; $i++){
$thestr=$thestr."a";
}
echo $thestr;
?>

解决方案 »

  1.   

    <?php
    $num=10;
    $thestr="a";
    for ( $i=1; $i<=$num-1; $i++){
    $thestr=$thestr."a";
    }
    echo $thestr;
    ?>这么写是对的,我试了一下,好几天没用php了,害得我还把apache重启了一下。结果结果是正确的
      

  2.   

    str_pad("a", $num, "a");
    str_repeat("a", 3);
      

  3.   

    <?php
    $num=10;
    $thestr="a";
    for ( $i=1; $i<=$num-1; $i++)
    $thestr=$thestr."a";
    echo $thestr;
    ?>

    <?php
    $num=10;
    $thestr="a";
    for ( $i=1; $i<=$num-1; $i++){
    $thestr=$thestr."a";
    }
    echo $thestr;
    ?>
    有区别吗?
      

  4.   

    请问 ccterran(iwind) 大哥:str_pad和str_repeat这两个函数在哪里弄来的?