Revision: 44114
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 6, 2011 10:46 by browncardigan
Initial Code
<?php $file = 'path-to-class-file'; $file_contents = @file_get_contents($file); if ($file_contents !== NULL) { $file_contents = trim(str_replace(array('<?php', '<?', '?>'), '', $file_contents)); // remove php tags $file_contents = substr($file_contents, 0, strlen($file_contents)-1); // remove the last chracter - ie. the } bracket $functions = explode('function ', $file_contents); $functions_array = array(); foreach ($functions as $f_key => $function) { $key = trim(current(explode('(', $function))); if ($f_key == 0) { $class_start = $key; } else { $functions_array[$key] = $function; } } ksort($functions_array); echo '<textarea style="width:100%;height:100%">'; echo '<?php' . "\n" . $class_start . "\n\n" . 'function ' . implode('function ', $functions_array) . "\n\n" . '}'; echo '</textarea>'; } ?>
Initial URL
Initial Description
pass in a php class and sort the methods alphabetically. great for 'fucking huge' class files where you can't find methods.
Initial Title
alphabetise class methods
Initial Tags
Initial Language
PHP