- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$pattern = "/\/(?<backendLanguage>\w{2})\/?((?<frontendLanguage>\w{2})\/?)?\/?((?<cooperation>\w+)\/?)?/";
$sample = 'tyre24.dev/de/de';
echo (int)preg_match( $pattern, $sample, $matches).PHP_EOL;
print_r($matches);