- get_defined_constants: documentation ( source)
- array_keys: documentation ( source)
- usort: documentation ( source)
<?php
$consts = get_defined_constants();
$consts = array_keys($consts);
usort($consts, function($a, $b) {
return strlen($b) <=> strlen($a);
});
foreach($consts as $const){
echo strlen($const).": ".$const."\n";
}