FirstBorn Posted July 5, 2009 Share Posted July 5, 2009 Hi, Thank you for your help. I have a script that I'm running that is supposed to generate a random 16 character number (can be changed,) but the results when going to print it display nothing. <?php function generate_passwd($length = 16) { static $chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789'; $chars_len = strlen($chars); for ($i = 0; $i < $length; $i++) $password .= $chars[mt_rand(0, $chars_len - 1)]; return $password; } ?> What am I missing here? Thank you very much for your help. Thanks, FirstBorn Link to comment https://forums.phpfreaks.com/topic/164837-getting-blank-results-on-generating-blank-password-script/ Share on other sites More sharing options...
haku Posted July 5, 2009 Share Posted July 5, 2009 $chars_len = strlen($chars); for ($i = 0; $i < $length; $i++) $chars_len != $length Link to comment https://forums.phpfreaks.com/topic/164837-getting-blank-results-on-generating-blank-password-script/#findComment-869159 Share on other sites More sharing options...
.josh Posted July 5, 2009 Share Posted July 5, 2009 use { } instead of [ ] when treating a string like an array Link to comment https://forums.phpfreaks.com/topic/164837-getting-blank-results-on-generating-blank-password-script/#findComment-869174 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.