In this case, you will need to use the function preg_replace_callback. In preg_replace_callbackyou can go through the closure and make effective changes by getting matches. you can get a match from $ matches held in close
if($actions && $Links)
{
foreach ($Links as $key => $value)
{
$url = preg_replace_callback(
"/(?:\{)([a-zA-Z0-9_]+)(?:\})/",
function($matches) use($data)
{
return $data[$matches[1]];
},
$value['url']
);
$action .= '<a href="'.$url.'" >'.$value['text'].'</a>';
}
}
(?:\{) . , , . module_id item_id, .