<?php
function f($text, $l="ru")
{
$pspell_link = pspell_new($l);
$a=$text;
$text_s=$text;
$array_razdelitel=array(" ",".",",","!","?",";",":","_","=","+","&","@",""","'","(",")","<",">","\","/","`","~","$","[","]","{","}","|","#","%","^","*",); $a=str_replace(PHP_EOL, " ", $a);
$a=str_replace($array_razdelitel," ",$a);
$a=str_replace(array('1','2','3','4','5','6','7','8','9','0','№',), "", $a);
$a=preg_replace('| +|', ' ', $a);
$a=explode(" ",$a);
$errors='';
foreach($a as $v)
if(!pspell_check($pspell_link, $v))
{
$slova = pspell_suggest($pspell_link, $v);
$text=str_replace($v, "<font color="red">$v</font>", $text);
$voz=(strlen($slova[0])>0)?implode(", ", $slova):"Нет возможных вариантов";
$errors.="Ошибка в слове $v. Возможные варианты: $voz
";
$text_s=(strlen($slova[0])>0)?str_replace($v, $slova[0], $text_s):$text_s;
}
$errors=($errors)?$errors:"Ошибок нет";
echo "<table border="1px"><tr><td>Тест</td><td>$text</td></tr><tr><td>Ошибки</td><td>$errors</td></tr><tr><td>Рекомендуемый текст</td><td>$text_s</td></tr></table>";
}
?>