Prova cosi. Non testato.
Codice PHP:function wrongwords($text)
{
$words = str_word_count($text,1);
$conn = mysqli_connect('127.0.0.1','root','','esame') or die("Connection failed: " . $conn->connect_error);
foreach ($words as $word)
{
$query = mysqli_query($conn,"SELECT * FROM vocabolario WHERE vocabolo like '%$word%'");
if(mysqli_num_rows($query) == 0)
{
$t= "<u>$word</u>";
$text = preg_replace("/\b$word\b/", $t, $text);
}
}
echo $text;
$conn->close();
}


Rispondi quotando
