- preg_match: documentation ( source)
- print_r: documentation ( source)
- array_shift: documentation ( source)
<?php
$input = "12 XY 123456789";
if (preg_match('/^(?:(\d+)\s*)?(A|B|DF|XY)(?:\s*(\d+))?$/', $input, $matches)){
array_shift($matches);
print_r($matches);
}