drb88830 2011-01-24 02:10 采纳率: 0%
浏览 34
已采纳

多次回显PHP变量

How would one go about echoing a variable multiple times..

A way to understand this question better would be if I said:

$foo = '<div>bar</div>';
echo $foo*7;

It's probably the most simple thing, but I'm not sure.

And

  • 写回答

5条回答 默认 最新

  • douyu4535 2011-01-24 02:11
    关注

    In this simple case, you can use str_repeat().

    $foo = '<div>bar</div>';
    echo str_repeat($foo, 7);
    

    Reference: PHP string functions

    For anything more complex, a loop is usually the way to go.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?