Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/01/2016, 11:38
x_atrix
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: PHP archivos, encontrar palabra y sustituir

Usa alguna de estas funciones:
str_replace($buscar, $reemplazar, $cadena)
[URL="http://php.net/manual/es/function.str-replace.php"]http://php.net/manual/es/function.str-replace.php[/URL]

preg_replace($buscar, $reemplazar, $cadena)
[URL="http://php.net/manual/es/function.preg-replace.php"]http://php.net/manual/es/function.preg-replace.php[/URL]

strtr($cadena, $buscar, $reemplazar)
[URL="http://php.net/manual/es/function.strtr.php"]http://php.net/manual/es/function.strtr.php[/URL]

La variable $cadena contendría el contenido del archivo. Para obtenerlo puedes usar file_get_contents() por ejemplo ...
[URL="http://php.net/manual/es/function.file-get-contents.php"]http://php.net/manual/es/function.file-get-contents.php[/URL]

Última edición por x_atrix; 09/01/2016 a las 11:41 Razón: Añadir links