hehe, forgot to remove the echo $string line... whoops ;)
Should be:
<?
function checkSpelling ( $string )
{
$wordlist = preg_split('/\s/',$string);
$words = array();
for($i = 0; $i < count($wordlist); $i++)
{
$word = trim($wordlist[$i]);
if(!preg_match('/[A-Za-z]/', $word))
continue;
$word = preg_replace('/[^\w\']*(.+)/', '\1', $word);
$word = preg_replace('/([^\W]*)[^\w\']*$/', '\1', $word);
$word = trim($word);
if(!in_array($word, $words, true))
$words[] = $word;
}
$misspelled = $return = array();
$int = pspell_new('en');
foreach ($words as $value)
if (!pspell_check($int, $value))
$misspelled[] = $value;
foreach ($misspelled as $value)
$return[$value] = pspell_suggest($int, $value);
return $return;
}
?>