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 = trim(join('', array_map(function($word) use ($array) { return $word . (in_array($word, $array) ? "&nbsp;" : ' '); }, $words))); echo $titleNew; // "Testing w&nbsp;it's ul.&nbsp;here"

preferences:
80.54 ms | 408 KiB | 5 Q