phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


String: Spell Checking

Tag: string, word, spell check   Category: PHP Basic
post: 03 Feb 2008 read: 146


PHP String Tips: If we want to check are spelled corectly, we have php functions: pspell. These functions allow you to check the spelling of a word and offer suggestions. Your php must be compiled with pspell support (need the aspell library).


<?
$str = "ceck this sentenc. Help me!";

$dict = pspell_new("en", "british");
$words = str_word_count($str, 1);

foreach($words as $v){
	if(!pspell_check($dic, $v)){
		$errors[] = $v;
	}	
}

if(sizeof($errors) > 0){
	echo "error words: ".implode(", ",$errors);
}

?>

Next information aspell http://aspell.sourceforge.net/.




| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
CAPTCHA - part 3 : "Are you human or ....?" (Build Your CAPTCHA)

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting