PHP - Select 5 random characters in a string? -


how can randomly select 5 characters given string? can repeat.

say string this:

static $chars = "123456789bcdfghjkmnpqrstvwxyzbcdfghjklmnpqrstvwxyz"; 

i want 5 random characters out of variable. can me out!

function gen_code() {      $charset = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz1234567890";      return substr(str_shuffle($charset), 0, 5); } 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -