Jump to content

Editing a file


tobeyt23

Recommended Posts

This is what a came up with:

 

<?php
$_file      = 'text.txt';
$_contents  = file_get_contents($_file);
$_replace   = "Replaced";
$_find      = '###FIND###';
$_contents  = str_replace($_find, $_replace, $_contents);
$_fo        = fopen($_file,"w") or die ("Error editing.");

fputs($_fo,$_contents);
fclose($_fo) or die ("Error Closing File!");
?>

Link to comment
https://forums.phpfreaks.com/topic/214730-editing-a-file/#findComment-1117222
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.