12.7. Spell Checking

PHP offers spell checking through the Pspell library, which is a replacement for the older Aspell library.

integer pspell_add_to_personal(integer configuration, string word)

The pspell_add_to_personal function (Listing 12.73) adds a word to a personal dictionary. You must supply a configuration link as created by pspell_new_config.

Listing 12.73. pspell_add_to_personal
<?php
    //create a configuration link
    $config = pspell_config_create("en");

    //set path to personal words
    pspell_config_personal($config, "/tmp/custom.pws");

    //load dictionary
    $new_config = pspell_new_config($config);

    //add word to dictionary
    pspell_add_to_personal($new_config, "Leon");

    //save personal dictionary
    pspell_save_wordlist($new_config);
?>

integer ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.