我有一个数组,看起来像这个
Array
(
[CALLGUID] => 200667992044
[CALLERID] => +9167555555
[CALLDATEEST] => 2014-08-13
[CALLTIMEEST] => 01:21:30
[COUNTRY] =>
[LOCALCALLTIME] => 16:00:00
[LOCALDATE] => 1969-12-31
[REGIONID] => 0
[DOW] => 0
)
我不知道CALERID中是否有"+",所以我可以做一些计算,我尝试了一些不同的方法,如substr和array_search,但我运气不好。这就是我现在的处境。。
while($r = mysqli_fetch_assoc($regionCheck)) {
if(array_search('+',$r['CALLERID'])){
echo "Inside + removing the +, it is an international call." ."'n";
}
有人能帮忙吗?
因此,首先,您使用array_search()
不正确。您需要向它传递一个数组$r
,而不是一个字符串$r['CALLERID']
。我也找不到一个+
,所以我改变了你的if
语句,在$r['CALLERID']
上使用了strstr()
,因为你已经知道你在看哪个键了,你不需要到处乱跳。直接瞄准它。
if(strstr($r['CALLERID'],"+")){
echo "Inside + removing the +, it is an international call." ."'n";
}
这将产生您期望的代码结果。