Generate random username based on full name php
<p>I want to grab the first name in lowercase then concatenate the first two characters after the space and finally concatenate that with a random number from 0 to 100.
So if my name is <code>"Mike Test"</code> I want the output to be: <code>mikete3</code></p>

<pre><code>function random_username($string) {
    $pattern = " ";
    $firstPart = strstr(strtolower($string), $pattern, true);
    $secondPart = substr(strstr(strtolower($string), $pattern, false), 0, 3);
    $nrRand = rand(0, 100);

    $username = $firstPart.$secondPart.$nrRand;
    return $username;
}

echo random_username("Mike Test");
</code></pre>

<p>My function outputs "mike te84" and I don't know how to remove that space.</p>