but reading your post again, and assuming that you're always going to supply a string which will be split into 4 parts (only the third of which you want to keep) then why not do as you've done and then do something really simple like:
$important_bit = $ex[2];
and then you can do your maths stuff on $important_bit.
Or am i missing something?
PS Also, there are 6 parts to your array ($ex[0] which contains "protocol://" through to $ex[5] which contains "/")