public function entriesToArray($entries=array())
{
$list = array();
for($i=0;$i<$entries['count'];$i++)
{
$row = array();
$dn = $entries[$i]['dn'];
unset($entries[$i]['count']);
unset($entries[$i]['dn']);
foreach($entries[$i] as $key=>$value)
{
if (is_int($key))
{continue;}
$list_in_col = array();
foreach($value as $key2=>$value2)
{
if (!is_int($key2))
{continue;}
$list_in_col[] = $value2;
}
$row[$key] = $list_in_col;
}
$row['dn'] = $dn;
$list[$i] = $row;
}
return $list;
}
/*
Format ldap entries to better array
array (size=2)
'count' => int 1
0 =>
array (size=14)
'ou' =>
array (size=2)
'count' => int 1
0 => string '03024' (length=5)
0 => string 'ou' (length=2)
'mail' =>
array (size=2)
'count' => int 1
0 => string 'name.surname@myfirm.cz' (length=22)
1 => string 'mail' (length=4)
'telephonenumber' =>
array (size=2)
'count' => int 1
0 => string '+420123456781' (length=13)
2 => string 'telephonenumber' (length=15)
'personaltitle' =>
array (size=2)
'count' => int 1
0 => string 'Ing.|' (length=4)
3 => string 'personaltitle' (length=13)
'sn' =>
array (size=2)
'count' => int 1
0 => string 'MySurname' (length=6)
4 => string 'sn' (length=2)
'givenname' =>
array (size=2)
'count' => int 1
0 => string 'MyName' (length=5)
5 => string 'givenname' (length=9)
'count' => int 6
'dn' => string 'cn=mynickid,ou=users,o=mydepartmentid' (length=24)
array (size=1)
0 =>
array (size=7)
'ou' =>
array (size=1)
0 => string '03024' (length=5)
'mail' =>
array (size=1)
0 => string 'name.surname@myfirm.cz' (length=22)
'telephonenumber' =>
array (size=1)
0 => string '+420123456781' (length=13)
'personaltitle' =>
array (size=1)
0 => string 'Ing.|' (length=4)
'sn' =>
array (size=1)
0 => string 'MySurname' (length=6)
'givenname' =>
array (size=1)
0 => string 'MyName' (length=5)
'dn' => string 'cn=mynickid,ou=users,o=mydepartmentid' (length=24)
*/