Advertisement
Wistaro

Générateur_nom_planètes_sconquest

Jul 17th, 2015
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.62 KB | None | 0 0
  1. <?php
  2.  
  3. function genere_nom_pl(){
  4.    
  5.     $mots = array("bleu","blanc","rouge","jaune","vert","violet","affichera",
  6. "chaine","genre","retourne","fonction","commentaire","lapin","renard","image",
  7. "mathematique","aleatoire","hasard","source","chat","souris","chapeau","langue",
  8. "arbre","generer","livre","supposon","tout","vecteur","construction","violon",
  9. "flute","fuite","zebre","zoro","xylophone","deux","trois","quatre","cinq","sept"
  10. ,"huit","neuf","douze","treize", "star", "etoile", "maska", "wistaro", "vaisseau", "machin", "bidule", "pooo", "xylophone", "classement", "youtube", "marcel", "ordinateur", "camera", "marron", "william", "kevin", "kapla", "fou", "findus", "fuite", "fonction", "programme", "papa", "maman", "physique");
  11.      
  12.     $p = 2;
  13.  
  14.    
  15.    
  16.     $m1 = $mots[rand(0,count($mots)-1)];
  17.     $result=substr($m1,0,rand(2,strlen($m1)-1));
  18.  
  19.     for($i=0;$i<rand(3,4);$i++){
  20.         $pasOk=true;
  21.         $x =0;    
  22.         while($pasOk && $x<100){
  23.            
  24.             $m = $mots[rand(0,count($mots)-1)];
  25.             while($m==$m1){
  26.                 $m = $mots[rand(0,count($mots)-1)];
  27.             }
  28.            
  29.             if(eregi(substr($result,-$p),$m)){
  30.                 $pasOk=false;
  31.                 $m2 = split(substr($result,-1),$m);
  32.                 $result .= substr($m2[1],0,rand(2,strlen($m2[1])-1));
  33.             }
  34.             $x++;
  35.         } if($x==100){ return genere_nom_pl;}
  36.  
  37.     }
  38.     if(strlen($result)<4) return genere_nom_pl();
  39.     return $result;
  40.    
  41.     }
  42.  
  43.     $distinction = rand(10, 100);
  44.     $nom_final = genere_nom_pl().$distinction;
  45.  
  46.     echo $nom_final;
  47.  
  48.    
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement