/ Published in: PHP
                    
                                        
In my app, we have to auto-generate usernames for our users, here is the code I did.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
<?php
function generarUsername($nombre, apellido_paterno, $apellido_materno, $max_size = 8)
{
$tentativo = false;
$i = 0;
while($tentativo == false && $n != $nombre && $i<15)
{
if(self::getByUsername($tentativo)){
//This function check if the tentative username is available
$tentativo = false;
}
$i++;
}
return $tentativo;
}
?>
Comments
 Subscribe to comments
                    Subscribe to comments
                
                