Code:
$testing="sniper this and sniper that";
$connectors=array('and', 'now', 'but', 'still', 'so', 'only', 'therefore', 'moreover', 'besides', 'consequently','nevertheless', 'for', 'however', 'hence', 'either', 'or', 'neither', 'nor', 'both', 'also','while', 'then', 'who', 'which', 'that', 'although', 'though', 'since', 'until', 'as', 'if','after', 'before', 'how', 'once', 'when', 'lest', 'why', 'unless', 'because', 'till', 'where', 'whether','the', 'a', 'an','about', 'above', 'across', 'after', 'against', 'along', 'among', 'around', 'at', 'before', 'behind','below', 'beneath', 'beside', 'between', 'beyond', 'but', 'by', 'despite', 'down', 'during', 'except','for', 'from', 'in', 'inside', 'into', 'like', 'near', 'of', 'off', 'on', 'onto', 'out', 'outside', 'over',
'past', 'since', 'through', 'throughout', 'till', 'to', 'toward', 'under', 'underneath', 'until', 'up', 'upon','with', 'within', 'without','who', 'whom', 'whose', 'which', 'that', 'this', 'these', 'those', 'I', 'Me', 'You', 'He', 'him', 'she','her', 'it', 'we', 'us', 'they', 'them', 'Mine', 'Yours', 'His', 'Hers', 'Its', 'Ours', 'Theirs', 'whoever','whomever', 'whichever', 'myself', 'yourself', 'himself', 'herself', 'itself','ourselves', 'yourselves', 'themselves');
foreach($connectors as $word)
{
$pattern="/".strtolower($word)."/";
$data=preg_replace($pattern,"/ /", $testing);
}
echo $data."<br>";
echo $testing;
Output:
sniper this and sniper that
sniper this and sniper that
Expected output:
sniper this and sniper that
sniper sniper
What am I doing wrong?