mysql database
Keywords are distinguished by letters | symbols
php code
The function that needs to be implemented: determine whether the text message sent by the user contains keywords
$needle = 'Where is your company address'; $data = db('zdhf')->select(); foreach($data as $v1){ $rule_name=$v1['rule_name']; $content = $v1['content']; if(strstr($rule_name, '|')!== false){//| is used to distinguish $content_array = explode("|",$rule_name);//Use | to split the string into an array foreach($content_array as $v2){ if(strstr($needle, $v2)!== false){ return $content; } } }else{ if(strstr($needle,$rule_name)!== false){ return $content; } } $content =''; //If you can execute it here, it means that the keyword contained in the information sent by the user has not been found. If it is found, it has jumped out of the loop above. }