関数を優先して表示させたいなどがあれば、「array_merge」する順番を入れ替え、「sort」をしなければ上に来るはず。(試してない)
<?php
$keywords = array(
'if'
, 'else'
, 'elseif'
, 'endif'
, 'while'
, 'endwhile'
, 'do'
, 'as'
, 'for'
, 'endfor'
, 'foreach'
, 'endforeach'
, 'break'
, 'continue'
, 'switch'
, 'endswitch'
, 'case'
, 'default'
, 'declare'
, 'enddeclare'
, 'try'
, 'catch'
, 'return'
, 'exit'
, 'const'
, 'class'
, 'function'
, 'require'
, 'include'
, 'require_once'
, 'include_once'
, 'abstract'
, 'final'
, 'interface'
, 'private'
, 'protected'
, 'public'
, 'static'
, '__LINE__'
, '__FILE__'
, '__DIR__'
, '__FUNCTION__'
, '__CLASS__'
, '__METHOD__'
, '__NAMESPACE__'
);
$functions = get_defined_functions();
$constants = function_exists('get_defined_constants') ? get_defined_constants() : array();
$interfaces = function_exists('get_declared_interfaces') ? get_declared_interfaces() : array();
$classes = function_exists('get_declared_classes') ? get_declared_classes() : array();
$arrays = array_merge(
$keywords
, $functions['internal']
, array_keys($constants)
, $interfaces
, $classes
);
sort($arrays);
$arrays = array_unique( $arrays );
echo implode("\n", $arrays);
コメント