title: how to get value from url after using regular expression?
body: <p>I am trying to make functionality used by routes by my own.</p>
  
  <p>I have some url say,</p>
  
  <blockquote>
    <p>$url1 = /profile/user/10/ </p>
    
    <p>$url2 = /profile/{some_variable}/settings/{some_integer}</p>
  </blockquote>
  
  <p>Regular expression for url1,</p>
  
  <blockquote>
    <p>'/profile/user/[0-9]+/$/'</p>
  </blockquote>
  
  <p>Regular expression for url2</p>
  
  <blockquote>
    <p>'/profile/[a-z]+/settings/[0-9]+/$/'</p>
  </blockquote>
  
  <p>Description,
  I am trying to check whether a certain url exists or not in my routes folder which I can achieve by using preg_match() between by url and the regular expression.</p>
  
  <p>I want to get the value '10' from </p>
  
  <blockquote>
    <p>$url1 = /profile/user/10/</p>
  </blockquote>
  
  <p>and {some_variable}, {some_integer} from </p>
  
  <blockquote>
    <p>$url2 = /profile/{some_variable}/settings/{some_integer}</p>
  </blockquote>
  
  <p>So that I can pass these variables in my controller function.</p>
  
  <p>Please help.</p>
  
  <p>Edit: I have an array which holds regular expressions for URLs, When a url is hit, I get that url and match it inside the array whether it exists or not. If it does I need to get the variables used in url.</p>
  
  <pre><code>Array (
      [specific_user] =&gt; Array
          (
              [url] =&gt; /profile\/user\/[0-9]+\/$/
              [className] =&gt; user
              [methodName] =&gt; userinfo
          )
  
      [specific_user_check] =&gt; Array
          (
              [url] =&gt; /profile\/user\/[a-z]+\/$/
              [className] =&gt; user
              [methodName] =&gt; userinfo
          )
  
      [user_settings] =&gt; Array
          (
              [url] =&gt; /profile\/user\/settings\/$/
              [className] =&gt; user
              [methodName] =&gt; settings
          )  )
  </code></pre>
  
  <p>Here,</p>
  
  <blockquote>
    <p>$myUrl = /profile/user/10/</p>
  </blockquote>
  
  <p>if $myUrl matches with the regular expression in array, then I need to get  value '10'.</p>
  
  <p>Note: (.*) is used somehow to get the desired result.</p>