3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $toppings1 = array("Pepperoni", "Cheese", "Anchovies", "Tomatoes"); $toppings2 = array("Ham", "Cheese", "Peppers"); $inttoppings = array_intersect($toppings1, $toppings2); $difftoppings = array_diff($toppings1, $toppings2); $bothtoppings = array_merge($toppings1, $toppings2); $bothtoppings = array_unique($bothtoppings); var_dump($inttoppings); var_dump($difftoppings); var_dump($bothtoppings); ?>
based on mK3mL
Output for 4.3.0 - 7.2.0
array(1) { [1]=> string(6) "Cheese" } array(3) { [0]=> string(9) "Pepperoni" [2]=> string(9) "Anchovies" [3]=> string(8) "Tomatoes" } array(6) { [0]=> string(9) "Pepperoni" [1]=> string(6) "Cheese" [2]=> string(9) "Anchovies" [3]=> string(8) "Tomatoes" [4]=> string(3) "Ham" [6]=> string(7) "Peppers" }