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