3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('w','z','u','o','ul.'); $titleOld = 'Testing w it\'s ul. here'; $words = explode(' ', $titleOld); $titleNew = rtrim(join('', array_map(fn($word) => $word . (in_array($word, $array) ? "&nbsp;" : ' '), $words))); echo $titleNew; // "Testing w&nbsp;it's ul.&nbsp;here"

preferences:
25.73 ms | 408 KiB | 5 Q