I’m trying to process an imported XML file and make the text in one of the nodes
<Name>SOMETHINGTOMAKELOWERCASE</Name>
lowercase
<Name>somethingtomakelowercase</Name>
So far I got:
$xml = file_get_contents($xmlfile);
$xml = preg_replace('/<Name>(.*)<\/Name>/e', '<Name>' . strtolower($1) . '</Name>',$xml);
fwrite(fopen($xmlfile, 'wb'), $xml);
I’ve tried about ten different versions of the regexp, but none of them will work. Could you please point me in the right direction as to the correct regexp?
Try this instead:
When using the /e modifier in preg_replace, you have to pass a string of code to be evaluated as the replacement parameter, not an already-evaluated expression.