PHP format multiple entries from textarea regex : <p>I can get the number from a file using Regex and PHP for example:</p>

<pre><code>&lt;?PHP
  $txt='house.1x01.pilot.ws_dvdrip_xvid-fov.mp4';
  if ($c=preg_match_all ("/.*?(\\d+).*?(\\d+)/is", $txt, $matches))
  {
      $int1=$matches[1][0];
      $int2=$matches[2][0];
      print "($int1) ($int2) \n";
  }
?&gt;
</code></pre>

<p>but what i want to do is for instance, enter multiple file names in a text área and convert this:</p>

<pre><code>house.1x02.paternity.ws_dvdrip_xvid-fov.mp4
house.1x03.occams_razor.ws_dvdrip_xvid-fov.mp4
house.s04e15.dvdrip.xvid-orpheus.mp4
</code></pre>

<p>into this</p>

<pre><code>INSERT INTO `tvshow` (`id`, `show_id`, `season`, `episode`, `file`) VALUES (NULL, '18', '1', '2', 'house.1x02.paternity.ws_dvdrip_xvid-fov.mp4');

INSERT INTO `tvshow` (`id`, `show_id`, `season`, `episode`, `file`) VALUES (NULL, '18', '1', '3', 'house.1x03.occams_razor.ws_dvdrip_xvid-fov.mp4');

INSERT INTO `tvshow` (`id`, `show_id`, `season`, `episode`, `file`) VALUES (NULL, '18', '4', '15', 'house.s04e15.dvdrip.xvid-orpheus.mp4');
</code></pre>

<p>Format it for SQL, removing the 0 just keeping the 1 2 3, etc. and not 01 02 03 make it easier to copy-paste the query and insert into the database. As there is so many file names, kind of time-consuming doing it one by one.</p>

<p>is there any better way to acquire this?</p>
