$url = 'http://example.com/subdomain1/product/123123/variable-text-goes-here';
$path = parse_url($url)['path'];
echo explode('/', $path)[1];
If your PHP is < 5.4, use this:
$url = 'http://example.com/subdomain1/product/123123/variable-text-goes-here';
$urlParts = parse_url($url);
$path = $urlParts['path'];
$subdomain = explode('/', $path);
echo $subdomain[1];