3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str1 = "Samsung Television 21 Inches LED BH005DE"; $str2 = "Samsung 21 Inch LED TV"; //synonyms: $syns = [ 'TV' => ['TV', 'Television'], 'Inch' => ['Inch', 'Inches'] ]; //replace: $str1 = array_reduce(array_keys($syns), function($c, $x) use ($syns) { return $c = preg_replace('/\b'.join('\b|\b', $syns[$x]).'\b/', $x, $c); }, $str1); //now, str1 looks like "Samsung TV 21 Inch LED BH005DE" $str2 = array_reduce(array_keys($syns), function($c, $x) use ($syns) { return $c = preg_replace('/\b'.join('\b|\b', $syns[$x]).'\b/', $x, $c); }, $str2); //now, str2 looks like "Samsung 21 Inch LED TV" $arr1 = explode(' ', $str1); $arr2 = explode(' ', $str2); var_dump(array_diff($arr1, $arr2));//['BH005DE']
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [5]=> string(7) "BH005DE" }

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:
49.08 ms | 401 KiB | 8 Q