<?php $allowed_characters = array(1,2,3,4,5,6,7,8,9,0); for($i = 1;$i <= 12; $i++){ $pass .= $allowed_characters[rand(0, count($allowed_characters) - 1)]; } echo $pass; ?>