Replace whole string with stars

php, replace

Solution

$string = str_repeat('*', strlen($string));

Simply make a new string, consisting of all stars, with length equal to the original.

Problem

I need a solution to replace whole string with stars in PHP, for example there are strings like: test test123 test1234 And depends on string length, it will replace string with the stars like: `test` has 4 characters in length so it will be replaced with 4 stars `****`. `test123` has 7 characters in length so it will be replaced with 7 stars `*******`. And so on... Is there any good solution for that?

Original source