Doubt - Generate random string of 6 characters in PHP

0

So, how do I generate a string like this:

Z8Yjv.jpg

I went to get a photo of a user here from Stack-OverFlow and the name of the photo came like this. I had thought of something like this:

<?php

$string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

echo substr(str_shuffle($string), 0, 6);

?>

What is the probability of generating the same string? ... And if it is wrong that way, then what is the best way to generate it?

    
asked by anonymous 09.03.2018 / 05:02

0 answers