Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/08/2004, 18:22
Avatar de sir_notos
sir_notos
 
Fecha de Ingreso: noviembre-2001
Ubicación: Mexicali
Mensajes: 709
Antigüedad: 24 años, 11 meses
Puntos: 1
Código PHP:
<?php
function gen_rand_string()
{
    
$chars = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
            
'i', 'j', 'k', 'l', 'm', 'm', 'n', 'o',
            
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
            
'x', 'y', 'z', '1', '2', '3', '4', '5',
            
'6', '7', '8', '9', '0');

    
$max_chars = count($chars) - 1;

    
srand((double) microtime()*1000000);

    
$rand_str = '';
    for(
$i=0; $i < 8; $i++)
    {
        
$rand_str = $rand_str . $chars[rand(0, $max_chars)];
    }

    return 
$rand_str;
}
?>
Pieza de codigo tomada de PHPbb

tambien puedes darle un MD5()
lego str_shuffle()
leugo
substr($str,0,12); o algo asi :)

cheka aqui para ver mas funciones de manejo de string
http://mx2.php.net/manual/en/ref.strings.php
__________________
Usuario Registrado de linux #374849

Última edición por sir_notos; 24/08/2004 a las 18:23