Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hello. i really need a help regarding the usage of trim function in my code. i want to remove the "." in the end of my sentence. but the real problem is when the period is connected with the word for example : "this is a test."
My purpose if one of the words is spelled incorrectly(using pspell)analyse if it wrong.
My output would be test is spelled incorrectly because of the period at the end, which is wrong since test is spelled correctly.
this is my code. please see why does the trim function doesnt work. I need help. please.
and regarding an english grammar check. will someone give me some samples of code.
thank you very much.Code: Select all
//explodes into sentences
//explodes into words
//checks spelling ang tags the word.
<?php
include("ecsel_connectdb.php");
$var= trim($_POST['textfield']);
$mypar=explode('.',$var);
foreach($mypar as $b)
{
echo "$b - This is a sentence";
echo "<br/>";
echo "<br/>";
}
$myarray=explode(' ',$var);
foreach($myarray as $a)
{
$pspell_link = pspell_new("en");
if (pspell_check($pspell_link, $a))
{
echo "$a - This is a valid spelling";
echo "<br/>";
echo "<br/>";
}
else
{
echo "$a - Sorry, wrong spelling";
echo "<br/>";
echo "<br/>";
$pspell_link = pspell_new("en");
if (!pspell_check($pspell_link, $a))
{
$suggestions = pspell_suggest($pspell_link,$a);
foreach ($suggestions as $suggestion) {
echo "Possible spelling: $suggestion<br />";
echo "<br/>";
echo "<br/>";
}
}
echo "<br/>";
echo " word: $a";
echo "<br/>";
echo "<br/>";
$sql="SELECT WORD FROM WORDS where WORD= '$a'";
$sql_result=mysql_query($sql,$connection) or die ("Couldnt execute query at WORDS");
$row= mysql_fetch_array($sql_result);
if($a==$row["WORD"])
{
$sql1= "SELECT MARK FROM WORDS where word ='$a'";
$sql_result1= mysql_query($sql1,$connection) or die ("Couldnt execute query at words");
$row1=mysql_fetch_array($sql_result1);
$dis = $row1["MARK"];
echo "$a is $dis";
echo "<br/>";
echo "<br/>";
}
else
{
echo "$a - noun";
echo "<br/>";
echo "<br/>";
}
}
}
$string= implode(' ',$myarray);
echo "string: $string";
echo "<br/>";
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]