Possible Duplicate:
Dynamically creating/inserting into an associative array in PHP
I have the following entries generated in a for loop.
CN=Group01,CN=Users,DC=cnn,DC=local - abc@xyz.net
CN=Group04,CN=Users,DC=cnn,DC=local - def@xyz.net
CN=Group02,CN=Users,DC=cnn,DC=local - mlb@xyz.net
CN=Group04,CN=Users,DC=cnn,DC=local - rst@xyz.net
How can I arrange them in an associative array, so, it looks like this:
Array
(
[Group01] => ([0]=>abc@xyz.net),
[Group02] => ([0]=>mlb@xyz.net),
[Group04] => (
[0]=>def@xyz.net,
[1]=>rst.net
)
)
The associative array does not need to have CN=Users, DC=cnn, DC=local string.
The code I have in the for loop is:
for ($i=0; $i < $entries["count"]; $i++)
{
if (isset($entries[$i]["mail"][0]) && isset($entries[$i]["memberof"][0]))
{
echo $entries[$i]["memberof"][0]." - ".$entries[$i]["mail"][0]."<br />";
}
}
Thanks
1 Answer