mirror of
https://github.com/myvesta/vesta
synced 2025-07-06 04:51:54 -07:00
13 lines
389 B
PHP
13 lines
389 B
PHP
<?php
|
|
|
|
function myvesta_replace_in_file($file, $find, $replace) {
|
|
if (!file_exists($file)) return myvesta_throw_error (3, "File '$file' not found");
|
|
|
|
$buf=file_get_contents($file);
|
|
|
|
if (strpos($buf, $find)===false) return myvesta_throw_error (4, "String '$find' not found");
|
|
|
|
$buf=str_replace($find, $replace, $buf);
|
|
$r=file_put_contents($file, $buf);
|
|
return $r;
|
|
}
|