3v4l.org

run code in 300+ PHP versions simultaneously
<?php $postcard = 'postcard'; $car = 'car'; $arr_postcard = str_split($postcard); $arr_car = str_split($car); function array_diff_once($array1, $array2) { foreach($array2 as $a) { $pos = array_search($a, $array1); if($pos !== false) { unset($array1[$pos]); } } return $array1; } $uncommon = count($arr_postcard) >= count($arr_car) ? array_diff_once($arr_postcard,$arr_car) : array_diff_once($arr_car,$arr_postcard); echo 'Letters not in common: ' . implode(' - ', $uncommon) . PHP_EOL; function array_intersect_once($array1, $array2) { $array = []; foreach($array1 as $a) { $pos = array_search($a, $array2); if($pos !== false) { $array[] = $a; } } return $array; } $common = count($arr_postcard) >= count($arr_car) ? array_intersect_once($arr_car,$arr_postcard) : array_intersect_once($arr_postcard,$arr_car); echo 'Letters in common: ' . implode(' - ', $common) . PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
Letters not in common: p - o - s - t - d Letters in common: c - a - r

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:
26.5 ms | 405 KiB | 5 Q