Sorry to bring this up again, but I still can't get this working the way I want it to.
Here's some code:
$dir = "somedir";
$blah = opendir($dir);
while (false !== ($file = readdir($blah)))
{
if($file == "." || $file == "..")
{
}
else
{
$path = $dir . "/" . $file;
$fp = fopen($path, "r+");
$contents = fread($fp,filesize($path));
if(ereg("THEN BEGIN [0-9]",$contents))
{
rewind($fp);
$string = substr_replace($contents,'j',-1,0)
$write = fwrite($fp,$string,strlen($string));
}
}
From my rudimentary understanding of regexp, this should search for THEN BEGIN 0 -> THEN BEGIN 9 and then substr_replace counts back 1 place from the right side of the string and inserts a j in there.
However, this of course isn't working. Any thoughts? I've read that preg_match is a better option than regexp in quite a few places. But I haven't the foggiest on how to create preg expressions.
Any help is, as always, appreciated.