I have a lot of movies in directories with filenames containing their dimensions.
- descriptor-800x600.mov
- cool_animation-720p.mp4
- reactor-1080p.mov
- test-640x480.mov
I'm looking to pull out the 800, 600 from #1. 720 from #2, 1080 from #3, etc.
Looking for some help to tweak what I've got so far:
$re = '/^(.*?)\-(\d{3,4})p+|(\d{2,4})x(\d{2,4})+\.mov|mp4$/';
preg_match($re, $filename ,$matches);
Matches for #1: (Getting some extra stuff I don't need...?)
Array
(
[0] => 800x600.mov
[1] => {empty_string}
[2] => {empty_string}
[3] => 800
[4] => 600
)
Matches for #2:
Array
(
[0] => testing-720p
[1] => testing
[2] => 720
)
I've obviously got something wrong, any input would be greatly appreciated!