how can I convert a string from an array into first small letters depending on the amount of letters?
Like Greg turns into gggg, jimmy returns jjjjj, Hello World turns into hhhhhhhhhhh.
Well, you can get the first letter, then, the size and just use the str_repeat() and strtolower() functions to create the required results. Something like this:
$string = “This is silly!”;
$new_string = str_repeat(strtolower(substr($string,0,1)), strlen($string));
echo $new_string;
This will display “tttttttttttttt”…
Hope that is what you are asking for…
1 Like