3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
34.17 ms | 406 KiB | 5 Q