I have an issue with an array being returned from an API request which i want to search for a specific value and perform a certain operation for but i have been unsucessful in making it work. I have used array_search() function and done several things based on reading similar questions here and online but still no luck. Anyone know what i am doing wrong?
$responses = explode("
", file_get_contents($url));
print_r($responses);
print_r($responses) displays:
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
)
and this is what i currently have in my code for array search
if(array_search("error_code=101", $responses)){
echo "Incorrect!";
}
The result i get from:
print_r(file_get_contents($url));
is
destination_msisdn=23345678 country= countryid= operator= operatorid= authentication_key=XXXXX error_code=101 error_txt=Destination MSISDN out of range
Please I am not trying to explode any array value I am trying to search for a string in the array and perform an operation as per my if statement.
Thanks