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"); usort($data,'mysort'); //print_r($data); $current = ""; for($i=0;$i<count($data);$i++) { $current=$data[$i]; for($j=$i+1;$j<count($data);$j++) { $current=str_replace($data[$j],"",$current); } if ($current!="") { echo $i." ".$current."\n"; } } ?>
Output for 4.3.0 - 7.1.0
0 1 2 3 kaushik 4 great 5 is