You need to use the use
keyword to pull in $array
into your anonymous function...
return preg_replace_callback ( '#\{([a-z0-9\-_]*?)\}#Ssi' , function ($matches) use ($array) {
return ( ( isset ( $array[$matches[1]] ) ) ? $array[$matches[1]] : '' );
} , $template );