- array_intersect_key: documentation ( source)
- print_r: documentation ( source)
- get_defined_constants: documentation ( source)
- array_flip: documentation ( source)
- array_keys: documentation ( source)
- preg_grep: documentation ( source)
<?php
$constants = get_defined_constants();
print_r(array_intersect_key($constants, array_flip(preg_grep('/^P(?:REG|CRE)_/', array_keys($constants)))));