Consider the following string:
LoReM {FOO} IPSUM dolor {BAR} Samet {fooBar}
I'm looking for a way to lowercase everything - except what is between {brackets} should be ignored. So the desired output is:
lorem {FOO} ipsum dolor {BAR} samet {fooBar}
In another topic @stema pointed to http://de2.php.net/manual/en/functions.anonymous.php to achieve something like this, but I dont understand how:
echo preg_replace_callback('~\{.*?\}~', function ($match) {
return strtolower($match[1]);
}, 'LoReM {FOO} IPSUM dolor {BAR} Samet {fooBar}');
This returns only the string without the bracketed {tags}, and not even lowercased. Who can help me solve this? Any help is greatly appreciated :)