OK,我有一個比較值,並返回結果的功能,無論情況,即:設施間轉移=這裏設施間傳輸功能:
function fncResult ($expVal, $actVal)
{
$negNulls=array("-5","-10","-15","-20","-25");
if (!in_array($expVal, $negNulls))
{
if(strtolower($expVal)==strtolower($actVal))
{
echo "
<td class='match' title='The values match.'>Match</td>
</tr>";
}
else
{
echo "
<td class='notMatch' title='The values do not match.'>Not Match<br />No Match</td>
</tr>";
}
}
else
{
echo "
<td class='null' title='The value in the XML was a negative null.'>Negative Null</td>
</tr>";
}
}
它工作的時間約99%,除此以外,當它談到這一點:
//--Type of service requested
echo "
<tr>
<td>E02_04</td>
<td>Type of Service Requested</td>
<td>36. <Nature of Call></td>
<td>$fldServReq</td>
<td>".fncGrabNemsis("E02_04",$fldServReq,$local)."</td>
<td>".fncIsSet($CZ_E02_04[1])."</td>";
fncResult(fncGrabNemsis("E02_04",$fldServReq,$local),fncIsSet($CZ_E02_04[1]));
雖然看起來比較複雜,它真的只是一個用strtolower($ expVal)==用strtolower($ actVal),比較。當我回應被比較的值時,我得到:「interfacility transfer」和「interfacility transfer」和「No Match」... WTF?難道這是因爲第一個值來自XML(UTF-8),第二個來自數據庫(?)我不知道該怎麼做,並且由於這是一項簡單的任務而令人難以置信地感到沮喪。謝謝你的幫助!
爲什麼你不使用[strcasecmp](http://uk3.php.net/manual/en/function.strcasecmp.php)? – 2011-02-07 21:10:53
可能有空格。 `var_dump`並檢查它們的長度是否相等,或者先在輸入上嘗試`trim'。 – netcoder 2011-02-07 21:16:08