<?php
function hashJoin($table1, $index1, $table2, $index2) {
    
    foreach ($table1 as $s)
        $h[$s[$index1]][] = $s;
    
    foreach ($table2 as $r)
    	foreach ($h[$r[$index2]] as $s)
	    $result[] = array($s, $r);
    return $result;
}

$table1 = array(array(27, ),
           array(18, ),
           array(28, ),
           array(18, ),
           array(28, ));
$table2 = array(array(, ),
           array(, ),
           array(, ),
           array(, ),
           array(, ),
           array(, ));

foreach (hashJoin($table1, 1, $table2, 0) as $row)
    print_r($row);
?>