PHP如何產生具有可讀性的隨機字串?本文將分享一段隨機產生可讀性字串的程式碼,希望對大家有幫助。
此程式碼將建立一個可閱讀的字串,使其更接近字典中的單字,實用且具有密碼驗證功能。
/************** *@length - length of random string (must be a multiple of 2) **************/ function readable_random_string($length = 6){ $conso=array("b","c","d","f","g","h","j","k","l", "m","n","p","r","s","t","v","w","x","y","z"); $vocal=array("a","e","i","o","u"); $password=""; srand ((double)microtime()*1000000); $max = $length/2; for($i=1; $i<=$max; $i++) { $password.=$conso[rand(0,19)]; $password.=$vocal[rand(0,4)]; } return $password; }
相關推薦:
以上是PHP產生具有可讀性的隨機字串的詳細內容。更多資訊請關注PHP中文網其他相關文章!