3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // just comment/uncomment to choose which $data you want to see in action $data = array("kaushik","kaushik is","kaushik is great","is","is great","great"); //$data = array("usb","pc","cam 168","cam","168"); $current = ""; for($i=0;$i<count($data);$i++) { $current=$data[$i]; for($j=0;$j<count($data);$j++) { if($i<>$j) { if((str_replace($data[$j],"",$current))!=$current) { $data[$j]=""; }; } } } for($i=0;$i<count($data);$i++) { if($data[$i]!="") { echo $data[$i]."\n"; } } ?>
Output for 4.3.0 - 7.1.0
kaushik is great