3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vocabolario = array("la", "mia", "una", "prova", "con", "del", "testo"); function textCheck($text, &$vocabolario) { return preg_replace_callback('#(?!<.*?)\w+(?![^<>]*?>)#', function ($word) use ($vocabolario) { $word = $word[0]; if (preg_grep( "/".preg_quote($word)."/i" , $vocabolario)) { return $word; } return '<u>'.$word.'</u>'; }, $text); } echo textCheck("La mia รจ UNA provaa con del testo: <a href='http://pippo.it'>html</a>.", $vocabolario);

preferences:
26.53 ms | 406 KiB | 5 Q