At first, I wanted to write: $out=preg_split('/[\. x]/',$in,3,PREG_SPLIT_NO_EMPTY);
but because the title words can be dot delimited AND you don't want to capture the file suffix, I had to bin that method.
Barmar's method includes the file suffix, so that will require additional handling. Ravi's pattern isn't as refined as it could be.
Revo's method is inspired, but requires 4x as many steps as my pattern. Regex Demo Both of our methods require an additional function call to prepare the title. I find my method to be very direct and doesn't require any array filtering.
$input[]='1x5 Girl In The Flower Dress.mkv';
$input[]='2x6.English,.Fitz.or.Percy.avi';
foreach($input as $in){
preg_match('/(\d+)x(\d+)[ \.](.+)\..+/',$in,$out);
echo "<div>";
echo "Season $out[1] Episode $out[2] of ",str_replace('.',' ',$out[3]);
echo "</div>";
}
Output:
Season 1 Episode 5 of Girl In The Flower Dress
Season 2 Episode 6 of English, Fitz or Percy