Below recursive function i am trying to get array of codes. For example input 'bme4', output should be like [0]=>'bme'[1]=>'bm'[2]=>'b'. But the return value is null eventhough i can get the correct return value with var_dump().
function get_parent_cat_code($code, $category_codes) {
$parent_cat_code = substr($code, 0, -1);
if ($parent_cat_code != ''){
$category_codes[] = $parent_cat_code;
get_parent_cat_code($parent_cat_code, $category_codes);
} else {
var_dump($category_codes);
return $category_codes;
}
}