I'm hoping someone better at regular expressions can help me out on this one...
Basically, if I set a variable to a string of text, like:
$var1 = "Some text here<%code value=\"1\" type=\"work.html\" %code>link<%code end %code>";
And then run the following regex on it:
$var2 = preg_replace("/.?<%code name=\"1\" value=\"([a-zA-Z0-9]+.[a-zA-Z0-9]+)\" %code>([a-zA-Z]+)<%code end %code>.?/m", "<a href=\"./page.phtml?value=$1\">$2</a>", $var1);
It works.
(creating a link from the values inside the <code> tags)
HOWEVER....
if $var1 is assigned by reading in a file such as this:
$filename = "/path/to/file";
$file = fopen($filename);
$var1 = fread($file, filesize($filename));
fclose($file);
And I then run the same preg_replace() on it, it does NOT work.
I'm sure I'm missing something small here, but I can not figure out what it is.
Any help would be great!
Thanks.
-- Jason