Saturday, December 19, 2009

Spelling Checking in php

Spelling Check in php. Pass checking string to function and get result in from of any error.

function checkSpell($input)
    $word=new COM("word.application") or die("Cannot create Word object");
    $result= $doc->SpellingErrors->Count;
        echo "Input text contains misspelled words.\n\n";
        for($i=1; $i <= $result; $i++)
            echo "Original Word: " .$doc->SpellingErrors[$i]->Text."\n";
            echo "Suggestions: ";
            for($j=1; $j <= $list->Count; $j++)
                echo $correct->Name.",";
            echo "\n\n";
        echo "No spelling mistakes found.";

$str="Hellu world. There is a spellling error in this sentence.";

No comments:

Post a Comment