make string of N characters

David19801 picture David19801 · Jan 25, 2012 · Viewed 11.5k times · Source

Say I have a number=20 and a $value=7.

If I want to make a string of 20 7's using PHP. what's the quickest way to make this?

So output like:

$a='77777777777777777777';

Any functions to make this easier?

Answer

Eugen Rieck picture Eugen Rieck · Jan 25, 2012
$a=str_repeat($value,$number);