improve php function random string
<p>I have function, which generates a random string. It's ok but I want to generate unique numbers, this function returns generated numbers again.</p>
<pre><code>function getRandomString($length){
$validCharacters = &quot;12345678910&quot;;
$validCharNumber = strlen($validCharacters);
$result = &quot;&quot;;
    for($i = 0; $i &lt; $length; $i++){
        $index = mt_rand(0,$validCharNumber - 1);
        $result .= $validCharacters[$index];
    }
return $result;}

$x= getRandomString(2).substr(time(),-4);//rand(1000000,9999999);
</code></pre>