function niveau($cat_id,$A){ //echo $A; if(parent_id($cat_id)==0) { return $A; } else { niveau(parent_id($cat_id),$A+1); } } echo niveau(80,0); //considering the parent function works, returning the parent's id of its argument