Reputation: 1
How can I simplify this structure:
$properties = $rs->$domains[0];
$dn = $properties[0]->distinguishedname;
Because PHP gives error on such construction:
$dn = $rs->$domains[0][0]->distinguishedname
Upvotes: 0
Views: 80
Reputation: 10666
This should work, or rather none of them should work.
To access a member of a object using the ->
operator you don't need to use the $
twice, it should throw an error or warning of some kind as far as i know.
$properties = $rs->$domains[0];
$dn = $properties[0]->distinguishedname;
Should be:
$properties = $rs->domains[0];
$dn = $properties[0]->distinguishedname;
Likewise:
$dn = $rs->$domains[0][0]->distinguishedname;
Should be:
$dn = $rs->domains[0][0]->distinguishedname;
That's the only problem I can see with your code.
Upvotes: 3
Reputation: 12932
Only looking at it quick it seems as though your code should work as long as the data is actually there. Perhaps you try to fetch distinguishedname from a domain that has no properties?
What does the php error say? Do a *var_dump* on your data structure to see that it actually contains the data you expect that it does.
Upvotes: 0