Replace string in text file using PHP

Does this work: $msgid = $_GET[‘msgid’]; $oldMessage=””; $deletedFormat=””; //read the entire string $str=file_get_contents(‘msghistory.txt’); //replace something in the file string – this is a VERY simple example $str=str_replace($oldMessage, $deletedFormat,$str); //write the entire string file_put_contents(‘msghistory.txt’, $str);

Reformat string containing date with Javascript

one solution without regex: var expDate=”2016-03″; var formatExp = expDate.split(‘-‘).reverse().join(“https://stackoverflow.com/”); //result is 03/2016 alert(‘result: ‘ + formatExp); var formatExpShort = expDate.substring(2).split(‘-‘).reverse().join(“https://stackoverflow.com/”); //result is 03/16 alert(‘result short: ‘ + formatExpShort);