Copy CodeThe code is as follows:
$keyword = "asp php,jsp";
$keyword =str_replace ("", "", $keyword);
$keyword =str_replace ("", ",", $keyword);
$keyarr =explode (', ', $keyword);
for ($index =0; $index
{
$whereSql. = "and (Arc.title like '% $keyarr [$index]% ' Or arc.keywords like '% $key arr[$index]% ') ";
}
Echo $whereSql;
to support spaces and commas at the same time, you need to replace them with a uniform comma before replacing them with commas, then separating the strings with commas and looping through the SQL query statements. The
Str_replace is a commonly used string substitution function in PHP. The
explode is a function that is commonly used in PHP to divide the array into arrays.
http://www.bkjia.com/phpjc/765722.html www.bkjia.com true Span id= "Isbasedonurl" itemprop= "Isbasedonurl" >http://www.bkjia.com/phpjc/765722.html techarticle Copy code code as follows: PHP $keyword = "asp php , JSP "; $keyword =str_replace ("", "", $keyword); $keyword =str_replace ("", ",", $keyword); $keyarr =explode (', ', $keyword); for ($index =0; ....