gpt4 book ai didi

javascript - 一次搜索并显示多个单词。在 PHP 中

转载 作者:行者123 更新时间:2023-11-30 00:20:22 25 4
gpt4 key购买 nike

我有一个 php 脚本,可以搜索用户输入的单词并显示结果,但我需要使其能够搜索多个单词并显示它。

这些单词保存在数据库中。

现在我的代码仅接受将“word1”替换为“word2”

我需要将“word1”替换为“word2”+“word3”到“word4”,并且与用户类型一样多。

这是我当前的 PHP 代码:

function Search() {

$q = "SELECT * FROM words WHERE word_title = '" . str_replace('_', ' ', addslashes($_GET['word'])) . "';";
$res = mysql_query($q);
while($row = mysql_fetch_array($res)) {
$c.= '' . LNtoBR($row['word_desc']) . '';
}
$GLOBALS['content'].= $c;
$GLOBALS['content'].= '';
}

我尝试过这样的:

function Search() {

$q = "SELECT * FROM words WHERE word_title = '" . str_replace('_', ' ', addslashes($_GET['word'])) . "';";
$res = mysql_query($q);
while($row = mysql_fetch_array($res)) {
$c.= 'explode(' . LNtoBR($row['word_desc']) . '), implode(' . LNtoBR($row['word_desc']) . ')';
}
$GLOBALS['content'].= $c;
$GLOBALS['content'].= '';
}

但它不像 JavaScript 接受 split(something).join(something); 但我需要从数据库中获取字符串并将所有用户搜索的字符串行替换为任何我的数据库中存在的单词。谢谢。

最佳答案

抱歉,目前还不能发表评论。

使用 PHP str_replace用于搜索和替换您的单词。

另请查看 PHP nl2br而不是您正在使用的函数 (LNtoBR)。

关于javascript - 一次搜索并显示多个单词。在 PHP 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23296873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com