1<?php
2function randomPassword() {
3 $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
4 $pass = array(); //remember to declare $pass as an array
5 $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
6 for ($i = 0; $i < 8; $i++) {
7 $n = rand(0, $alphaLength);
8 $pass[] = $alphabet[$n];
9 }
10 return implode($pass); //turn the array into a string
11}
12
13echo randomPassword();
14?>
15