|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-01-24 11:55 UTC] mbiebl at messageconcept dot com
Description:
------------
I have the following code
$result = ldap_search($con, $dn, $filter, $justthese);
$entries = ldap_get_entries($con, $result);
and then the following code to iterate through the results
foreach ($entries as $e) { ... }
This code worked fine with 7.3 and now yields the following error with 7.4:
"Trying to access array offset on value of type resource"
ldap_get_entries() is supposed to return an array and var_dump($entries) prints
array(11) {
["count"]=>
int(10)
[0]=>
....
}
So something is at odds here. Why does PHP 7.4 think $entries is not an array?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 01:00:01 2025 UTC |
Hm, right. I guess I need to explicitly skip the "count" element now which is part of the $result array. foreach (array_slice($entries, 1) as $e) { .. } appears to work. Not sure if this is the cleanest solution though. WDYT?$result = ldap_search($con, $dn, $filter, $justthese); $entries = ldap_get_entries($con, $result); foreach ($entries as $e) { if ($e[$this->uidNameAttribute][0] == '') { continue; } $principal = array('uri' => 'principals/' . strtolower($e[$this->uidNameAttribute][0]),); foreach ($this->fieldMap as $key => $value) { if (isset($e[$value['ldapProperty']])) { $principal[$key] = $e[$value['ldapProperty']][0]; } } $principals[] = $principal; }