- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$url = "https://test.com/file/5gdxyYpb#_FWRc4T12baPrppZIwVQ5i18Sq16f7TXU82LJwY_BjE";
$pattern = "~https?://.*/\K([^#\s]+)#(\S+)~";
$res = preg_match($pattern, $url, $matches);
print_r($matches);