Hello everyone: Is it possible to do recursive this function? I can write it so linear. But only a finite number of loops. Thanks. Manuel Perez This is: function ($field, $arr_secuence_reverse) { if (count($arr_secuence_reverse) == 1) { return getPrimaryKey4Field($field,$arr_secuence_reverse[0],NULL); } if (count($arr_secuence_reverse) == 2) { $sel2 = select($arr_secuence_reverse[0],"pk as pk_current",NULL,$arr_secuence_reverse[1],"pk as pk_next",NULL); foreach ($sel2 as $n2=>$v2) { $res[$v2['pk_current']] = getPrimaryKey4Field($field,$arr_secuence_reverse[1],'fk_'.$arr_secuence_reverse[0]."='".$v2['pk_current']."'"); } } if (count($arr_secuence_reverse) == 3) { $sel3 = select($arr_secuence_reverse[0],"pk as pk_current",NULL,$arr_secuence_reverse[1],"pk as pk_next",NULL); foreach ($sel3 as $n3=>$v3) { $res[ $v3['pk_current'] ][ $v3['pk_next'] ] = getPrimaryKey4Field($field,$arr_secuence_reverse[2],'fk_'.$arr_secuence_reverse[1]."='".$v3['pk_next']."'"); } } if (count($arr_secuence_reverse) == 4) { $sel4 = select($arr_secuence_reverse[0],"pk as pk_current",NULL,$arr_secuence_reverse[1],"pk as pk_next",NULL); foreach ($sel4 as $n4=>$v4) { $sel5 = select($arr_secuence_reverse[1],"pk as pk_current",NULL,$arr_secuence_reverse[2],"pk as pk_next",NULL); foreach ($sel5 as $n5=>$v5) { $res[ $v4['pk_current'] ][ $v4['pk_next'] ][ $v5['pk_current'] ] = getPrimaryKey4Field($field,$arr_secuence_reverse[3],'fk_'.$arr_secuence_reverse[2]."='".$v5['pk_current']."'"); } } } if (count($arr_secuence_reverse) == 5) { $sel5 = select($arr_secuence_reverse[0],"pk as pk_current",NULL,$arr_secuence_reverse[1],"pk as pk_next",NULL); foreach ($sel5 as $n5=>$v5) { $sel6 = select($arr_secuence_reverse[1],"pk as pk_current",NULL,$arr_secuence_reverse[2],"pk as pk_next",NULL); foreach ($sel6 as $n6=>$v6) { $res[ $v5['pk_current'] ][ $v5['pk_next'] ][ $v6['pk_current'] ][ $v6['pk_next'] ] = getPrimaryKey4Field($field,$arr_secuence_reverse[4],'fk_'.$arr_secuence_reverse[3]."='".$v6['pk_next']."'"); } } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php