什么是 VB6 函数 PHP 中的 String$(数字,字符)的等价物


What is the equivalent of the VB6 function String$(number, character) in PHP

这里描述了该函数,基本上它的作用是创建一个包含许多字符的字符串,例如

strTest = String$(5, "a")

结果将是一个包含 5 个字符的字母"a"的字符串

strTest = "aaaaa"

现在,不要误会我的意思,我可以轻松地在 PHP 中制作 for 循环来完成此操作,但我想知道 PHP 核心中是否已经存在这样的函数。

是的,

看看str_repeat()函数:

echo str_repeat('a', 5); // aaaaa

是的,有一个:str_repeat .例:

$strTest = str_repeat('a', 5);

PHP中有str_repeat函数;

$strTest = str_repeat("a",5);

来源 : http://www.php.net/manual/tr/function.str-repeat.php