I need to change some dates in login.php files weekly. On stackexchange, I found the function below.
Together with my other code, it works fine on my localhost!
I’m just wondering why this guy chose to use explode and implode instead of str_replace()
I’m a great believer in “if it ain’t broke, don’t fix it” so I don’t really want to mess with it! Also, I don’t really understand what is going on!
function replace_string_in_file($filename, $string_to_replace, $replace_with){
$content=file_get_contents($filename);
$content_chunks=explode($string_to_replace, $content);
$content=implode($replace_with, $content_chunks);
file_put_contents($filename, $content);
}