A = $A; $this->B = $B; } } $Sug = array( new sugul(1,2), new sugul(3,4), new sugul(5,1), new sugul(3,1) ); for($i=0;$i<$SugHulk;$i++){ for($j=0;$j<$SugHulk;$j++){ if($Sug[$i]->B == $Sug[$j]->A && $Sug[$i]->B != $Sug[$j]->B ){ $Sug[] = new sugul($Sug[$i]->A, $Sug[$j]->B); } } } print_r($Sug); ?>