A little find and replace function for PHP, not tested, but theoretically should work.
Find and replace for files PHP.
function find_replace($find, $replace, $file, $case_insensitive = true)
{
if(!file_exists($file))
{
return false;
}
else
{
$contents = file_get_contents($file);
if($case_insensitive)
{
$output = str_ireplace($find, $replace, $contents);
}
else
{
$output = str_replace($find, $replace, $contents);
}
$fopen = fopen($file, 'w');
if(!$fopen)
{
return false;
}
else
{
$fwrite = fwrite($fopen, $output);
if(!$fwrite)
{
return false;
}
else
{
return true;
}
}
fclose($open);
}
}
pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster
CodeAngry commented: file_put_contents() ... he missed it :) +0
Echo89 9 Web Developer
coreyavis 13 Dev Poster
CodeAngry 11 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.