如何在文本中搜索类似的句子:
$search_input = "php beginner tutorial";
$sql = "select into mytable where
'$search_input' is ..something.. with `title_col`";
所以,我的结果应该是这样的:
PHP: A simple tutorial - Manual
PHP 101: PHP For the Absolute Beginner | Zend Developer ...
Beginners PHP Tutorials- Home and Learn
PHP 5 Tutorial - W3Schools
Beginner PHP Tutorial - 1 - Introduction to PHP - YouTube
PHP Tutorial for Beginners - Webmonkey
PHP Tutorial- Tutorials Point
我有时候可能会使用拆分字符串。
$search_input = "php beginner tutorial";
$search_input = explode(" ", $search_input);
$sql = "select into mytable where ";
for($i=0; $i<count($search_input); $i++){
$sql .= "`title_col` like '%$search_input[$i]%' ";
if($i != count($search_input)-1) $sql .= "or ";
}
//echo $sql; will be like below
//select into mytable where `title_col` like '%php%' or `title_col` like '%beginner%' or `title_col` like '%tutorial%'
//would you suggest me how to `order by` too?
但我的专栏title_col
是utf8_general_ci
,有些语言在句子之间没有空格。我怎么能这样做?