<?php

$pets = array(
	"кот"=>array("мяу", "царапается"),
	"пёс"=>array("гав", "кусается"),
	"хомяк"=>array("Пии", "кусается")
	);
	
function petComparison(array $pets){
	$compared = array();
	foreach($pets as $petOne=>$petOneProps){
		foreach($pets as $petTwo => $petTwoProps){
			if($petOne!=$petTwo && !in_array($petOne.$petTwo, $compared )){
				echo "$petOne или $petTwo ? \n";
				$propsNumber = max(count($petOneProps), count($petTwoProps));
				for($i=0; $i<$propsNumber; $i++){
					$property1 = "";
					$property2 = "";
					if(isset($petOneProps[$i])){
						$property1 = $petOneProps[$i]; 
					}
					if(isset($petTwoProps[$i])){
						$property2 = $petTwoProps[$i]; 
					}
					echo "$property1      $property2 \n";
				}
				$compared[] = $petOne.$petTwo; 
				$compared[] = $petTwo.$petOne;
			}
		}
	}
}


petComparison($pets);