- var_dump: documentation ( source)
- implode: documentation ( source)
<?php
$text = "Some test text string with stop-words: stw stw2 stopword stw3stw stopword2c";
$stopwords = array(
'stw',
'stopword'
);
$regexp = '/';
$regexp.= '(' . implode('|', $stopwords) . ')' . '/';
var_dump($regexp);