我有这个功能:
function GetListByKeywords($keywords)
{
$HOST_DB = "localhost";
$NAME_DB = "jobs";
$USER_DB = "root";
$PWD_DB = "";
$connect = mysql_connect($HOST_DB, $USER_DB, $PWD_DB);
$db = mysql_select_db($NAME_DB);
$table = split('[;]', $keywords);
$Log_query = mysql_query("SELECT id FROM employment") or die(mysql_error());
$p = 0;
while ($Res_user = mysql_fetch_array($Log_query)) {
$id[$p] = $Res_user;
$p++;
}
$Log_query = mysql_query("SELECT description FROM employment") or die(mysql_error());
$p = 0;
while ($Res_user = mysql_fetch_array($Log_query)) {
$responsabilite[$p] = $Res_user;
$p++;
}
$p = 0;
for ($i = 0; $i < sizeof($table); $i++) {
for ($j = 0; $j < sizeof($responsabilite); $j++) {
if (strcmp($table[$i], $responsabilite[$j]) > 0) {
$marques[$p] = $id[$j];
$p++;
}
}
}
return $marques;
}
我想将字符串$keywords
与$responsabilite
的字段进行比较。所以我将它转换为表$table
,然后我按照表格中的每个元素比较每个元素。所以我需要一个可以替换strcmp
的函数,因为我需要知道字符串$keywords
中是否存在$responsabilite[$i]
的元素