There are lots of methods to do that, the best one-liner could be to make use of explode:
echo explode("/occasions/", $url)[1];
Or if one thing might come after ‘occasions/xxxxxx’:
$url = "https://knowledge.aboss.com/v1/company/1001/101010/occasions/1524447/different/123456";
echo explode("/", explode("/occasions/", $url)[1])[0]; // 1524447
You can even use a regex with preg_match
:
$url = "https://knowledge.aboss.com/v1/company/1001/101010/occasions/1524447/different/123456";
$matches = [];
preg_match("~/occasions/(d+)~", $url, $matches); // captures digits after "/occasions/"
echo($matches[1]); // 1524447