title: PHP find multiple curly braces in a string and replace the text inside
body: <p>I have string in my database like</p>
  
  <pre><code>Label is {input:inputvalue} and date is {date:2013-2-2}
  </code></pre>
  
  <p>How can I extract input and inputvalue from the first brace, and date and 2013-2-3 from the second brace and so on? So that displays like</p>
  
  <pre><code>Label is &lt;input name="input" value="input_value"&gt; and date is &lt;input name="date" value="2013-2-2"&gt; 
  </code></pre>
  
  <p>Below function works only if the string has {input} or {date}</p>
  
  <pre><code>function Replace_brackets($rec){
      $arr = array(" &lt;input name="input" value='input'&gt; ",
                   " &lt;input name="date" value='date'&gt; ");
      $arr1 = array('{input}','{date}');
      $itemvalue=str_replace($arr1,$arr,$rec);
      return $itemvalue;
  }
  </code></pre>
  
  <p>There might be more or less braces on the text such as 2 input braces and 4 date braces.</p>
  
  <p>Any ideas?</p>