拆分关键字查询单个零件循环

I have Chinese php search queries.

I want to split up any query up into individual characters.

ex: 你好 (ni hao, hello) split into 你 and 好

my query is set like:

$q = $_REQUEST["q"];

the results I want to split is set up like:

$results4 = $db->query( "SELECT CHS, PIN, DEF FROM FOUR 
                         WHERE CHS LIKE '%".$q."%' OR PIN LIKE '%".$q."%'");
while ($row4 = $results4->fetchArray()) {

How can I split up the keyword and look up all the components?

If you want it all in one query you will have to generate the whole query. If you were looking for an exact match you could use something similar to the in_array() function, but with LIKE it doesn't work.

You could however loop through the array of characters and put together the WHERE part programatically.

Like this

$where = array();
foreach ( $qtwo as $word ) {
   $where[] = "CHS LIKE '%" . $word . "%'";
}

$where = implode(' OR ', $where);

Use this $where variable in your query

You can use str_split to convert a string in an array of chars

$chars = str_split($q)