title: Php parse string error
body: <p>I am extracting files from a string which can be entered by a user or taken from reading a page source.</p>
  
  <p>I want to extract all .jpg image URLs</p>
  
  <p>So, I am using the following (example text shown) but a) it only returns the first one and b) it misses off '.jpg'</p>
  
  <pre><code>$word1='http://';
  $word2='.jpg';
  
  $contents = 'uuuuyyyyyhttp://image.jpgandagainhereitishttp://image2.jpgxxxxcccffff';
  
  $between=substr($contents, strpos($contents, $word1), strpos($contents, $word2) - strpos($contents, $word1));
  
  echo $between;  
  </code></pre>
  
  <p>Is there maybe a better way to do this?</p>
  
  <p>In the case of parsing a web page I cannot use a simple DOM e.g. <code>$images = $dom-&gt;getElementsByTagName('img');</code> as sometimes the image references are not in standard tags</p>