具体数值我有我要搜索一个特定值并执行特定操作的API请求返回一个数组的问题,但我一直在做它的工作不成功的。我已经使用array_search()函数,并根据在这里和在线阅读类似的问题做了几件事情,但仍然没有运气。任何人都知道我做错了什么?搜索阵列
$responses = explode("\n", file_get_contents($url));
print_r($responses);
的print_r($回应)显示:
Array
(
[0] => destination_msisdn=233887
[1] => country=
[2] => countryid=
[3] => operator=
[4] => operatorid=
[5] => authentication_key=XXXXXX
[6] => error_code=101
[7] => error_txt=Destination MSISDN out of range
)
,这就是我目前在我的代码为阵列搜索
if(array_search("error_code=101", $responses)){
echo "Incorrect!";
}
结果我从获得:
print_r(file_get_contents($url));
是
destination_msisdn=23345678 country= countryid= operator= operatorid= authentication_key=XXXXX error_code=101 error_txt=Destination MSISDN out of range
请不要试图炸开任何数组值我试图在数组中搜索一个字符串并根据我的if语句执行操作。
谢谢
您可以将'print_r(file_get_contents($ url));'的结果添加到您的问题中吗? – KhorneHoly
问题是什么? – Rizier123
@ Rizier123问题是我想在if语句不回显 – Unicornese