- strpos: documentation ( source)
- array_search: documentation ( source)
- array_filter: documentation ( source)
- printf: documentation ( source)
<?php
$allIntlCharConstants = (new ReflectionClass('IntlChar'))->getConstants();
$constants = array_filter($allIntlCharConstants, function($name){
return strpos('CHAR_CATEGORY_', $name) !== false;
});
IntlChar::enumCharTypes(function($start, $end, $type) use ($constants) {
printf("U+%04x through U+%04x are in category %d\n", $start, $end, array_search($type, $constants));
});