<?php

 function getYouTubeXMLUrl( $url) {

    $xml_youtube_url_base = 'https://w...content-available-to-author-only...e.com/feeds/videos.xml';
    $preg_entities        = [
        'channel_id'  => '\/channel\/([^\/?]+)', //match YouTube channel ID from url
        'user'        => '\/user\/([^\/?]+)', //match YouTube user from url
    ];

    foreach ( $preg_entities as $key => $preg_entity ) {
        if ( preg_match( '/' . $preg_entity . '/', $url, $matches ) ) {
            if ( isset( $matches[1] ) ) {
				return [
						'rss' => $xml_youtube_url_base . '?' . $key . '=' . $matches[1],
                        'id' => $matches[1],
                        'type' => $key,
                    ];
            }
        }
    }
}

// works
$url = 'https://y...content-available-to-author-only...e.com/channel/UCBLAoqCQyz6a0OvwXWzKZag/asdasd';

$channel = getYouTubeXMLUrl($url);
print_r($channel);

// doesn't work
$url = 'https://y...content-available-to-author-only...e.com/channel/UCBLAoqCQyz6a0OvwXWzKZag?hello=worlddddddd';
$url = 'https://y...content-available-to-author-only...e.com/channel/UCBLAoqCQyz6a0OvwXWzKZag/hello';

