function flattenChildren(array $array, $key) { $chain = !empty($array['children']) ? flattenChildren($array['children'], $key) : array(); array_unshift($chain, $array[$key]); var_dump($chain); return $chain; }
function replaceInheritence($matches) { list($all, $file, $class) = $matches; $hier = getClassHierarchy($class, $file); $hier_text = ''; if (count($hier['parents']) > 0) { $hier_text = '*Parent Classses: '; foreach ($hier['parents'] as $p_class) { $hier_text .= " {{MAYBECLASS:{$p_class}}}"; } $hier_text .= "\n"; } if (count($hier['children']) > 0) { $hier_text .= "*Child Classes:\n"; $hier_text .= flattenChildren($hier['children']); } return $hier_text; }