This is probably an easy one, but I couldn't figure it out after searching. I managed to alter the output 20 different ways, but none of them were what I want from it =D
<?php
$text = <<<DATA
Show.Name.2x05.HDTV.x264
Show.Name.2x06.HDTV.x264
Show.Name.2x07.HDTV.x264
Show.Name.2x08.HDTV.x264
Show.Name.2x09.HDTV.x264
DATA;
$text = preg_replace('/([0-9]{1,2})x([0-9]{2})/e',
'sprintf("S%02dE%02d", $1, $2)', $text);
echo $text;
?>
Output
Show.Name.S02E05.HDTV.x264
Show.Name.S02E06.HDTV.x264
Show.Name.S02E07.HDTV.x264
Show.Name.S02E00.HDTV.x264
Show.Name.S02E00.HDTV.x264
As you can see it turns my 08 and 09 into 00, my best guess is this is related to PHP thinking I'm trying to indicate octal, as it is a base8 system it only likes 0-7. I didn't think a leading zero in a "string" would indicate that though? How can I alter my code to accept 08 and 09 but not change them to 00? I tried a few ways to try and escape it but i'm stuck.