Reputation: 1399
Lets say the string is Motive S01E13 HDTV x264 EVOLVE eztv I need to find out which episode is in this string. It is Obviously season 1 episode 13. I need to extract the 13 out of the string. I'm newer to PHP . So, lets say:
$title = 'Motive S01E13 HDTV x264 EVOLVE eztv';
I need to find 'E' and see if the next two characters are Numerical values. I assume... Thanks ahead of time!
Upvotes: 4
Views: 282
Reputation: 146191
You may try this
$title = 'Empire S01E13 HDTV x264 EVOLVE eztv';
preg_match('/e(\d{2})/i', $title, $matches);
echo $matches[1]; // 13
Upvotes: 1
Reputation: 3712
I think this is what you're looking for:
$title = 'Motive S01E13 HDTV x264 EVOLVE eztv';
preg_match('/s\d\de(\d\d)/i', $title, $matches);
echo $matches[1]; // 13
This will output 13
, like you're looking for. It will work on any similarly formatted string, and will always output the episode number (as long as the format S00E00 is always followed). It is also case insensitive, if you care about that.
Upvotes: 2