dongrong8972 2014-07-27 17:44
浏览 15

PHP使用空格爆炸,但如何找到两个单词匹配

For a news script I want to recognize the content the user filled in about artists. So if they mention an artist I want to put this in an external database and when somebody views the article they can see the related artists that comes with the article they're reading. But I'm having a sort of creativity problem which holds me back. I use a explode function to seperate the words:

function multiexplode ($delimiters,$string) {
    $ready = str_replace($delimiters, $delimiters[0], $string);
    $launch = explode($delimiters[0], $ready);
    return  $launch;
}

$pieces = multiexplode(array(",",".","|",":","<",">"," "), $_POST['article_content']);

So if I have mentioned the artist Afrojack for example I can find it back in the $pieces array. Works well but found a problem. If for instance the user mentioned Nicky Romero, the artist is spread over two arrays and I can't possibly find it in my database filled with artists. So I thought of looking through two words, three words and everything but there has to be simple way I think. So my question is, how do I fix the problem that the script can only find oneword artists.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大