Hi all, preg-Replace has stumped me again. I'm just too thick to get it.
This is my problem:
I have two files. File 'newvalues.php' with an array like so:
.... $lang['this_key'] => 'blah blah blah'; $lang['another_key'] => 'rhubarb rhubarb'; $lang['something_else_key'] => 'twitter twitter'; ....
And another file: 'template.php' like so:
$lang = array( .... 'this_key' => 'some other value', 'something_else_key' => 'an old value', 'another_key' => 'spaghettiness', .... };
What I need is some preg_replace stuff to replace the values in the template.php file with the values in the newvalues.php file.
Before you ask, no I have no control over the format, these are what I have to work with. I also HAVE to have the working file in the template.php format, even though the newvalues.php file would do the same job!
I've been working along the lines of
$newcontent = preg_replace($regex,$newvalue,$tmpfilecontents);
Unfortunately, it's the regex I've been struggling with. I trying to do this
'a_key'(whitespace)=>(whitespace)'(content_to_replace)' for it, but I'm going around in circles.
Anybody shed some light on this for me?