3v4l.org

run code in 300+ PHP versions simultaneously
<?php $src = ["apple", "cherry", "grape", "lemon", "orange", "strawberry", "cherry", "cherry"]; $dst = ["apple", "banana", "cherry", "orange", "pear", "cherry"]; $result = []; while ($src && $dst) { if ($src[0] === $dst[0]) { // align identical values $result[] = [array_shift($src), array_shift($dst)]; continue; } $earliestSrcMatch = array_search($src[0], $dst); $earliestDstMatch = array_search($dst[0], $src); if ($earliestSrcMatch === $earliestDstMatch) { //both false (not 0) $result[] = [array_shift($src), null]; $result[] = [null, array_shift($dst)]; continue; } elseif ( $earliestDstMatch === false || ( $earliestSrcMatch !== false && $earliestSrcMatch < $earliestDstMatch ) ) { while ($dst && $src[0] !== $dst[0]) { $result[] = [null, array_shift($dst)]; } } elseif ( $earliestSrcMatch === false || $earliestSrcMatch > $earliestDstMatch ) { while ($src && $src[0] !== $dst[0]) { $result[] = [array_shift($src), null]; } } } while ($src) { $result[] = [array_shift($src), null]; } while ($dst) { $result[] = [null, array_shift($dst)]; } 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>";
Output for git.master, git.master_jit, rfc.property-hooks
<table border=1> <tr> <td>1</td> <td>apple</td> <td>apple</td> </tr> <tr> <td>2</td> <td></td> <td>banana</td> </tr> <tr> <td>3</td> <td>cherry</td> <td>cherry</td> </tr> <tr> <td>4</td> <td>grape</td> <td></td> </tr> <tr> <td>5</td> <td>lemon</td> <td></td> </tr> <tr> <td>6</td> <td>orange</td> <td>orange</td> </tr> <tr> <td>7</td> <td>strawberry</td> <td></td> </tr> <tr> <td>8</td> <td></td> <td>pear</td> </tr> <tr> <td>9</td> <td>cherry</td> <td>cherry</td> </tr> <tr> <td>10</td> <td>cherry</td> <td></td> </tr> </table>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
119.81 ms | 408 KiB | 5 Q