Ask for the different keywords to judge
This post was last edited by OKGEF on 2015-10-28 10:43:24
If I set some keywords $words= "Hello | inquiry | weather | name | data";
How to judge the submitted $_post[' POST ' This content contains the key words, so as to make different judgments
Currently only use Strpos () >0 such if, and then if,......else{}
Is there any other way to do that?
Is the content of the submission if there is a "hello" run a code, if it contains "weather" Run B code, multiple keywords are included in the first occurrence of the
------to solve the idea----------------------
$post = ' name query ';
if (Preg_match ('/(hello
------to solve the idea----------------------
Inquire
------to solve the idea----------------------
Weather
------to solve the idea----------------------
Name
------to solve the idea----------------------
Data)/I ', $post, $m)) {
$KEYW = $m [1];
Using switch is better
if ($keyw = = ' Hello ') {
echo ' Hello code ... ';
}elseif ($keyw = = ' query ') {
echo ' Query code ... ';
}elseif ($keyw = = ' weather ') {
Echo ' Weather code ... ';
}elseif ($keyw = = ' name ') {
echo ' name code ... ';
}elseif ($keyw = = ' data ') {
echo ' Data code ... ';
}
}