我有一个看起来像这样的数组
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
)
我不知道CALLERID中是否有“+”因此我可以做一些计算,我尝试过几种不同的方法,比如substr和array_search,但我没有运气。这就是我现在所处的位置..
while($r = mysqli_fetch_assoc($regionCheck)) {
if(array_search('+',$r['CALLERID'])){
echo "Inside + removing the +, it is an international call." ."\n";
}
有人可以帮忙吗?
答案 0 :(得分:2)
因此,首先,您错误地使用了array_search()
。您需要传递一个数组$r
,而不是字符串$r['CALLERID']
。我也无法找到+
,所以我改变了if
声明并在strstr()
上使用了$r['CALLERID']
,因为您已经确切地知道了哪个键正在看,你不需要四处跳舞。直接针对它。
if(strstr($r['CALLERID'],"+")){
echo "Inside + removing the +, it is an international call." ."\n";
}
这将产生您希望从代码中获得的结果。