Ver Mensaje Individual
  #11 (permalink)  
Antiguo 24/04/2011, 13:20
Jega_77
 
Fecha de Ingreso: abril-2011
Ubicación: El Salvador
Mensajes: 6
Antigüedad: 13 años
Puntos: 0
Respuesta: Leyendo archivos y agrupandolos

Excelente!!! abimaelrc, me distes la pista que necesitaba. Logré mi objetivo y mejor aún con un solo bucle. Mil gracias!!

Aquí dejo el código, talvez le sirva a alguien más.

Código PHP:
$path="D:\wamp\www\leyendo\esto";
$dir=dir($path);
$ano=2007;
$contador=1;

$xml = new SimpleXMLElement("<galeria></galeria>");
$albunes=$xml->addChild('albums');

    while (
$elemento $dir->read())
    {
        
$laExtension=strtolower(end(explode('.',$elemento)));                
        if ((
$laExtension == 'mp3') and ($elemento != '.') and ($elemento != '..')){

            
$ano_variante substr($elemento04);
            if(
$ano_variante!=$ano){
                
$ano=$ano_variante;
                
$album $albunes->addChild('album_'$ano);
                
$album->addAttribute('id',$contador);
                
$contador++;
            }             
            
$album->addChild('tracks'$elemento);                                      
        }
    }
$dir->close();


file_put_contents('musica.xml'$xml->asXML());