<?php $src = ["apple", "cherry", "grape", "lemon", "orange", "strawberry"]; $dst = ["apple", "banana", "cherry", "orange", "pear"]; $src = array_combine($src, $src); $dst = array_combine($dst, $dst); $combined_items = $src + $dst; ksort($combined_items); $result = []; foreach ($combined_items as $item) { $result[] = [ $src[$item] ?? null, $dst[$item] ?? null ]; } echo "<table border=1> "; foreach ($result as $i => [$s, $d]) { printf( "<tr> <td>%d</td> <td>%s</td> <td>%s</td> </tr>\n", ++$i, $s, $d ); } echo "</table>";
You have javascript disabled. You will not be able to edit any code.