Ver Mensaje Individual
  #6 (permalink)  
Antiguo 14/02/2010, 16:56
Avatar de Gulinaidas
Gulinaidas
 
Fecha de Ingreso: febrero-2010
Ubicación: La Plata, ARG
Mensajes: 88
Antigüedad: 14 años, 3 meses
Puntos: 1
Respuesta: Guardar txt intevertido

Fijate, q aca t dejo un ejemplo muy sencillo...seguro t sirve

Código PHP:
$texto ""
    
$directorio opendir("../TEST"); //Abrimos el directorio
    
while (($archivo readdir($directorio)) !== false)
    {
        if (
$archivo == "text.txt"//Seleccionamos el txt q queremos
        
{
            
$texto file_get_contents($archivo); // Obtenemos el texto del archivo
        
}
    }
    
closedir($directorio);
    
    
$nuevoTexto "hola " $texto//Creamos un nuevo string, con el nuevo texto mas el viejo
    
    
$fp=fopen("text.txt","w"); //Abrimos el archivo para escribir
    
fwrite($fp,$nuevoTexto,strlen($nuevoTexto)); //Insertamos el texto
    
fclose($fp); //Cerramos el archivo 
Saludos......!