function findChild(&$arr,$id) { $childs=array(); foreach ($arr as $k => $v) { if($v['parent_id']== $id) { $childs[]=$v; } } return $childs; }