3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [1, 3, 3, 3, 4, 7, 7, 8, 8]; $array2 = [0, 3, 3, 4, 4, 9, 9, 9]; $counts1 = array_count_values($array1); $counts2 = array_count_values($array2); $keepFrom1 = array_keys( array_filter( $counts1, fn($count, $number) => ($counts2[$number] ?? 0) <= $count, ARRAY_FILTER_USE_BOTH ) ); var_export( array_merge( array_intersect($array1, $keepFrom1), array_diff($array2, $keepFrom1) ) );
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 1, 1 => 3, 2 => 3, 3 => 3, 4 => 7, 5 => 7, 6 => 8, 7 => 8, 8 => 0, 9 => 4, 10 => 4, 11 => 9, 12 => 9, 13 => 9, )

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