mirror of
https://github.com/myvesta/vesta
synced 2025-08-21 05:44:08 -07:00
Create string.php
This commit is contained in:
parent
071e0d29a2
commit
31d3bade05
1 changed files with 13 additions and 0 deletions
13
func/string.php
Normal file
13
func/string.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?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;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue