3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function mysort($a,$b){ return strlen($b)-strlen($a); } //$data = array("kaushik","kaushik is","kaushik is great","is","is great","great"); $data = array("usb","pc","cam 168","cam","168"); usort($data,'mysort'); // print_r($data); $current = ""; for($i=0;$i<count($data);$i++) { $current=$data[$i]; for($j=0;$j<count($data);$j++) { if($i<>$j) { $current=(str_replace($data[$j],"",$current)); } } if ($current!="") { echo $current."\n"; } } ?>
Output for 7.0.0 - 7.1.0
usb cam 168 pc
Output for 4.3.0 - 5.6.28
168 cam usb pc