This question already has an answer here:
I have a URL which changes it position sometime
my urls look like
- https://video.twimg.com/ext_tw_video/841791481534803968/pu/vid/320x180/egCAExYQdRBw08fb.mp4
- https://video.twimg.com/ext_tw_video/841791481534803968/pu/vid/1280x720/GVsCGddpL9QoO4_B.mp4
- https://video.twimg.com/ext_tw_video/841791481534803968/pu/vid/640x360/33qcUEzFw-WS0inJ.mp4
In these url i need to extract "320x180" , "1280x720" , "640x360" There are more and the list goes on.
Plus the link changes like sometimes there is no /pu/vid/ part in the url. I tried with Php explode function but as position changes. Its hard to find them. for example
https://video.twimg.com/ext_tw_video/640x360/pu/vid/841791481534803968/33qcUEzFw-WS0inJ.mp4
for the constant part i was using this code
- $breaker=(explode("/",$video->url));
- $quality = $breaker[6];
But since they change places and their values differ. Is there any different approach to it? Also if the values stay same then how can i extract the URL of the video quality
like if the script finds the quality is 1280x720 then it will give me the url.and will loop through them to find different static video qualities?
https://video.twimg.com/ext_tw_video/841791481534803968/pu/vid/1280x720/GVsCGddpL9QoO4_B.mp4
</div>