I am trying to do preg_replace to replace underscore convention to camel case, but the ID needs to have always D uppercase, so e.g. from order_address_id
to orderAddressID
.
My code looks like below:
$patterns = array(
'#(' . $pregQuotedSeparator.')([A-Za-z]{1})#',
'#(^[id]{2})|([Id]{2})#',
);
$replacements = array(
function ($matches) {
return strtoupper($matches[2]);
},
function ($matches) {
return strtoupper('ID');
},
);
$filtered = $value;
foreach ($patterns as $index => $pattern) {
$filtered = preg_replace_callback($pattern, $replacements[$index], $filtered);
}
But I don't know why, it is changing to orderAIDressID
?