language: PHP (php 5.4.4)
date: 916 days 11 hours ago
link:
visibility: public
1
2
3
4
5
6
7
<?php
$arr = array('id' => 'really','foo' => 'bar','imp' => 'important');
$string = 'This should be {id} simple, {foo} and {imp}.';
 
$string = preg_replace('/{([a-zA-Z\_\-]+?)}/ie','$arr["$1"]',$string);
 
var_dump($string);