3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseStopWords($text){ $text = preg_replace('/[^a-zA-Z0-9áéíóúñ\', ]/i','',$text); $stopwords = array('a','ante','bajo','cabe','con','contra','de','desde','en','entre','hacia','hasta','para','por','sin','sobre','tras','el','lo','la','los','las','un','unos','una','al','del','que','es','se','y','fue'); foreach($stopwords as $w){ $text = preg_replace('/\b'.$w.'\b/i','',$text); } $text = preg_replace('/\s{2,}/i',' ',$text); return $text; } $texto = "Prueba de parseStop worlds para, probar la prueba"; var_dump(parseStopWords($texto));

preferences:
34.57 ms | 402 KiB | 5 Q