Generation d'un numero

helabah -  
avion-f16 Messages postés 19182 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,
Svp ,je veux un code php pour générer automatiquement des lettres et des chiffres.
par exemple bfc546.
merci
Configuration: Windows XP / Firefox 3.5.7

1 réponse

  1. avion-f16 Messages postés 19182 Date d'inscription   Statut Contributeur Dernière intervention   4 511
     
    Ça t'arrive de faire une recherche de temps en temps ?
    <?php
    
    function chaine_aleatoire() {
    	$string = "";
    	$chaine = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    	
    	srand((double) microtime() * 1000000);
    	$nb_car = rand(8,12);
    	
    	for($i = 0 ; $i < $nb_car ; $i++) {
    		$string .= $chaine[rand() % strlen($chaine)];	
    	}
    	return $string;
    }
    
    echo chaine_aleatoire();
    ?>
    0