fork download
  1. <?php
  2.  
  3. function convert($matches) {
  4. $season = str_pad($matches[1], 2, "0", STR_PAD_LEFT);
  5. $episode = str_pad($matches[2], 2, "0", STR_PAD_LEFT);
  6. return "S" . $season . "E" . $episode;
  7. }
  8.  
  9. $s = "Monk #7.11";
  10. echo preg_replace_callback("/#(\d+)\.(\d+)/", "convert", $s);
  11. echo "\n";
  12. $s = "Family Guy #5.6";
  13. echo preg_replace_callback("/#(\d+)\.(\d+)/", "convert", $s);
  14.  
  15. ?>
Success #stdin #stdout 0.03s 13064KB
stdin
Standard input is empty
stdout
Monk S07E11
Family Guy S05E06