Ver Mensaje Individual
  #13 (permalink)  
Antiguo 18/10/2008, 09:54
Avatar de uselox
uselox
 
Fecha de Ingreso: agosto-2008
Ubicación: Lima, Perú
Mensajes: 168
Antigüedad: 15 años, 8 meses
Puntos: 12
De acuerdo Respuesta: Ayuda, mostrar archivos aleatoriamente

Código PHP:
<?php 
/* 
   ******************************** 
   *        Created By RuzZ       * 
   *         Open Source          *  
   ******************************** 
                                  */ 
$dir='favorites/';  
if (
$handle opendir($dir)) { 
    while (
false !== ($file readdir($handle))) { 
        if (!
is_dir($dir.$file) && $file != "." && $file != "..") { 
            
$archivos[]=substr(urlencode($file), 0strlen(urlencode($file))-4); 
        } 
    } 
    
closedir($handle); 

/*|RuzZ And Paty|*/ 
$cantidad=count($archivos)-1
for(
$i=0;$i<=$cantidad;$i++)$lenght+=strlen($archivos[$i].","); 
$random=""
while(
$lenght!=strlen($random)) 

  for(
$i=0;$i<=$cantidad;$i++) 
  { 
    
$rand=mt_rand(0,$cantidad); 
//aca avia un peke error Compara con el anterior -.-
    
$posision=substr_count($random,$archivos[$rand].",");
    if(
$posision==false
    { 
      
$random.=$archivos[$rand].","
    } 
  } 

$cadena=substr($random,0,-1); 
$aleatorio=explode(",",$cadena);//new array random elemments 
//--- 
print_r($aleatorio); 
?>

Última edición por uselox; 26/11/2008 a las 23:06