<?php $string = 'I am flying from "Detroit to Vancouver" this to July'; $stopwords = array( "to", "anotherstopword", "andanother"); echo preg_replace('/"[^"\\\\]*(?>\\\\.[^"\\\\]*)*"(*SKIP)(*F)|\b(' . implode ('|', array_map('preg_quote', $stopwords)) . ')\b\h*/', '', $string);
You have javascript disabled. You will not be able to edit any code.