Back in 10/2002 csnyder at chxo dot com wrote the first comment about the spell functions, and wrote a very sophisticated spell check with a direct call to aspell. In a similar vein, I wrote a simplified a PHP function that will spell check a string and insert tags before and after the misspelled words. Auto-correction is not offered.
<?
function spellcheck($string) {
$pre='<strong>'; $post='</strong>'; $string=strtr($string,"\n"," ");
$mistakes = `echo $string | /usr/local/bin/aspell list`;
$offset=0;
foreach (explode("\n",$mistakes) as $word)
if ($word<>"") {
$offset=strpos($string,$word,$offset);
$string=substr_replace($string, $post, $offset+strlen($word), 0);
$string=substr_replace($string, $pre, $offset, 0);
$offset=$offset+strlen($word)+strlen("$pre $post");
};
return $string;};
?>
For this to work on your system, see if /usr/local/bin/aspell list runs from the shell. It needs to get input from standard input. You may not be able to run apell without the path for PHP because the PATH variable may be different in the PHP invocation from a shell invocation.