- print_r: documentation ( source)
- explode: documentation ( source)
- preg_replace: documentation ( source)
<?php
$str="This is a test - That game is awesome (Cristiano Ronaldo is a great Soccer Player)";
//first explode it
$e=explode(' ',$str);
//loop to remove short words and special characters
$out=array();
foreach ($e as $a){
$a=preg_replace("/[^A-Za-z0-9 ]/", '', $a);
if(strlen($a)>2){
$out[]=$a;
}
}
print_r($out);