title: PHP Match String Pattern and Get Variable
body: <p>I looked up some reference like <a href="https://stackoverflow.com/questions/16710286/match-string-and-get-variable-php">this question</a> and <a href="https://stackoverflow.com/questions/20943913/php-match-string-and-get-the-rest">this question</a> but could not figure out what I need to do.</p>
  
  <p>What I am trying to do is:</p>
  
  <p>Say, I have two strings:</p>
  
  <pre><code>$str1 = "link/usa";
  $str2 = "link/{country}";
  </code></pre>
  
  <p>Now I want to check if this the pattern matches. If they match, I want the value of country to be set usa.</p>
  
  <pre><code>$country = "usa";
  </code></pre>
  
  <p>I also want it to work in cases like:</p>
  
  <pre><code>$str1 = "link/usa/texas";
  $str2 = "link/{country}/{place}";
  </code></pre>
  
  <p>Maybe integers as well. Like match every braces and provide the variable with value. (And, yes better performance if possible)</p>
  
  <p>I cannot get a work around since I am very new to regular expresssions. Thanks in advance. </p>