title: Get file extension from curl request or string
body: <p>I have a cURL request:</p>
  
  <pre><code>$ch = curl_init('http://domain.com/file.ext');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FAILONERROR, true);
  
  $response = curl_exec($ch);
  $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
  $extension = '?' // How? 
  </code></pre>
  
  <p>and want to get the extension of URL, based on content type, but how?</p>
  
  <p>I have read about some regex, but, if my file have multiple dots, or extensions, like:</p>
  
  <pre><code>file.renamed.with.multiple.dots.png
  file.zip.rar
  </code></pre>
  
  <p>And, if I have a file like <code>file.ext</code> and known the content type is <code>image/png</code>, but the extension is not <code>png</code>?</p>
  
  <p>Thanks!</p>