Page 1 of 1

Need help to modify this script .

Posted: Wed Aug 04, 2004 4:58 am
by England
feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi all 


I've found this translation script on the web and it works properly .

This script doesn't depend on the database but on 

the separated text file as you can see on the script .

But I have a question :

1- In case of the result or the requested word not found 
How could I say ???? for example " Sorry this word doesn't exist"

Code: Select all

<html dir="rtl">
<head>
<title><?print $word;?></title>
</head>
<body>
<form action="trans.php" method="GET">
<center>
<div style="border:1px solid;background-color:white;width:50%">
<?print $mor1?>
<input type="text" name="word"><br>
<br>
<input type="submit" value="translate">
</div>
</center>
</form>
<hr>

<?
if($_GET[word])
{
$word = addslashes($_GET[word]);
$filename = 'translation.txt';
$fp = fopen($filename, "r");
$data = fread($fp, filesize($filename));
$split_data = explode("\n", $data);


print "<div style="background-color:white"> The definition of the word : $word<hr>";

for($i=0;$i < sizeof($split_data);$i++)
{
list($en, $ar) = explode("=>", $split_data[$i]);

if ($word === $en)
{
print $en." : <b>".$ar."</b><hr>\n";
break;
}
elseif(stristr($en,$word))
{
print $en." : <b>".$ar."</b><hr>\n";
}
}
}
?>
</div>
</body>
</html>
Thanks in advance .


feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Wed Aug 04, 2004 6:43 am
by kettle_drum
Do an if(!inarray());

Posted: Wed Aug 04, 2004 6:49 am
by feyd
and quote your named array elements..

Posted: Wed Aug 04, 2004 6:57 am
by England
Thank you for your rapid response .


Would you please explain more because I'm new to PHP .How could I

do ???? an if(!inarray()); according to above script .


Would you mind to write the php code .



Thanks once again .

Posted: Wed Aug 04, 2004 7:28 am
by zenabi

Posted: Wed Aug 04, 2004 7:56 am
by England
Thank you very much .