我有一个代码,假设它运行字典搜索引擎,但我刚刚启动并卡住了。这是我的完整代码。
<html>
<head>
<title><center>Dictionary</center></title>
</head>
<body>
<br><br>
<center>
<form action="" method=get>
<input type=text name=query style="font:11px arial; font-weight:bold; background:#FFFFDD;">
<input type=submit name=submit >
</form>
<br>
<br>
<br>
<table width=400 align=center><tr><td>
<?php
$txt_file= file_get_contents('dcdocument.txt');// << i put a path over here
$rows= explode("n", $txt_file);
foreach($rows as $row => $data)
{
//i have a long list of words and separated the words from definition using":::"
if ($row_data = ':::'){
explode(':::', $data);
};
$row_data = explode('::::', $data);
?>
</table>
<br> <br>
</center>
</form>
</body>
<html>
我想做的是用户在搜索引擎中输入单词,当他们按下"搜索"时,定义就会显示出来。我知道这是一个糟糕的开始,但我需要尽我所能的帮助来节省大量的时间。感谢
由于您正在尝试构建搜索引擎,因此可以使用preg_match
将字符串与用户搜索的内容相匹配。