I'm trying to use the backreference \\1 or \${1} in a preg_replace, however I'm not able to get it right. Here's an example of what I want to accomplish:
Code: Select all
$mytest->data['TEST'] = 'This is a regular test';
$text = '[TEST] based on my findings';
$new_text = preg_replace('/\[([^0-9](?:[A-Z0-9\-_]+))\]/', (isset($mytest->data['\\1']) ? $mytest->data['\\1'] : '') , $text);
print_r($new_text);
Hope some one can help me out.