I have some data being returned from an API that is in the following format:
string(15) "[email protected]"
bool(true)
string(7) "generic"
array(5) {
["server"]=>
string(19) "imap.mail.yahoo.com"
["username"]=>
string(15) "[email protected]"
["port"]=>
int(993)
["use_ssl"]=>
bool(true)
["oauth"]=>
bool(false)
}
array(0) {
}
When I am trying to parse this with a foreach loop, it is unsuccessful. I am assuming this is due to the string(15), bool(true), and string(7) pieces of data located above the actual array.
Here is my foreach loop:
$results = array();
foreach ($Request->getResults() as $imapSettings) {
$results['server'] = $imapSettings['server'];
$results['username'] = $imapSettings['username'];
$results['port'] = $imapSettings['port'];
$results['use_ssl'] = $imapSettings['use_ssl'];
$results['oauth'] = $imapSettings['oauth'];
}
When I run the code above, I get the following error: Warning: Illegal string offset 'server' in. And I believe this error is usually a sign that something is not an array.
So my question is how do I go about parsing this piece of data?
UPDATE:
Here is was var_dump($Request->getResults()); returns:
array(5) {
["email"]=>
string(15) "[email protected]"
["found"]=>
bool(true)
["type"]=>
string(7) "generic"
["imap"]=>
array(5) {
["server"]=>
string(19) "imap.mail.yahoo.com"
["username"]=>
string(15) "[email protected]"
["port"]=>
int(993)
["use_ssl"]=>
bool(true)
["oauth"]=>
bool(false)
}
["documentation"]=>
array(0) {
}
}
gettype($imapSettings)...???gettype($imapSettings)this is the outputstringbooleanstringarrayarray.