Question:
Date: 05-11-2021 13:30:32
(In Spanish)
De que forma podria yo modificar una linea o fila de un archivo. Ejemplo:
---------------
prueba.php
---------------
1 < ? php
2
3 LINEA/FILA QUE DESEO MODIFICAR
4
5
6
7
8
9
10 ? > Votes: 0 - Answers: 1 - Views: 6 Share on: Google Facebook Twitter LinkedIn Link
Modificar una linea/fila especifica de un archivo txt php html medienta PHP[Resolved]
Hola a todos.De que forma podria yo modificar una linea o fila de un archivo. Ejemplo:
---------------
prueba.php
---------------
1 < ? php
2
3 LINEA/FILA QUE DESEO MODIFICAR
4
5
6
7
8
9
10 ? > Votes: 0 - Answers: 1 - Views: 6 Share on: Google Facebook Twitter LinkedIn Link
Answers:
-
Date: 08-11-2021 09:42:02 He resuelto el problema con esta funcion.
function file_edit_contents($data, $file_patch='config.php'){ //Dividir y transformar cada linea del archivo en un array $file = explode("\n", rtrim(file_get_contents($file_name))); //Modificar lineas especificar el array almacenado en $file. Es este caso linea [3,6,9,12]. $file[3] = "'".$data["db_host"]."'"; $file[6] = "'".$data["db_user"]."'"; $file[9] = "'".$data["db_password"]."'"; $file[12] = "'".$data["db_name"]."'"; //Ya modificado, revertir el explode. $file = implode("\n", $file); //Guardar el archivo en la hubicacion file_put_contents($file_patch, $file); }
Votes: 1 - Link answer
To actively participate in the community first must authenticate, enter the system.Sign In