我正在尝试编写几行代码来制作不区分大小写的数组唯一类型函数.这是我到目前为止所拥有的:
foreach ($topics as $value) {
$lvalue = strtolower($value);
$uvalue = strtolower($value);
if (in_array($value, $topics) == FALSE || in_array($lvalue, $topics) == FALSE || in_array($uvalue, $topics) == FALSE) {
array_push($utopics, $value);
}
}
Run Code Online (Sandbox Code Playgroud)
问题是if语句.我认为我的语法有问题,但我对PHP比较新,我不确定它是什么.有帮助吗?
我有一个数据库查询,可以提取文本字符串
$descriptionsQuery = mysql_query("select prob_text from opencall where logdatex between $OneHourAgo and $TimeNow ORDER by callref DESC") or die(mysql_error());
$descriptions = array();
while ($row = mysql_fetch_assoc($descriptionsQuery)){
$descriptions[] = $row['prob_text'];
}
//put all the strings together with a space between them
$glue = implode (" ",$descriptions);
Run Code Online (Sandbox Code Playgroud)
我想要帮助的是......在"说明[]"被"粘合"为一个长字符串之前,我想要删除任何重复的单词.一旦他们被胶合,我依赖于每个原始描述中都有重复的单词.这有点难以解释,这是我的意思的一个例子.2个用户输入一些文本,例如User1:"I have an issue with Leeds server. I am in Leeds"
User2 : "Margaret in Leeds has a problem, please call margaret". 从这一点来说,我希望User1在最终的粘合字符串中只有1个"利兹",User2只有1个玛格丽特,但是两个用户都提到"利兹",所以我希望在胶合字符串中有两次,每个用户一次.这可能吗?任何帮助赞赏.