我需要從ldap查詢中轉換字符串。我正在查詢用戶帳戶的Active Directory服務器。這是我拉的字符串。PHP字符串嵌套數組
"CN=Phil Robertson,OU=Users,OU=Duck Commander,OU=Department & Buildings,DC=OCSDtest,DC=local"
我希望它轉換爲一個數組,看起來像這樣
$array['local']['OCtest']['Department & Buildings']['Duck Commander']['Users']['Phil Robertson']=1;
不
$array([1]=>'local,[2]=>'OCtest',[3]='Depart',[4]='Duck Commander',[5]='Users');
到目前爲止,我有
示例代碼---
$dnn2 = ldap_explode_dn("CN=Phil Robertson,OU=Users,OU=Duck Commander,OU=Department & Buildings,DC=OCSDtest,DC=local",1);
unset($dnn2['count']);
echo "<pre>";
print_r(array_reverse($dnn2));
我需要什麼?
你想要一個6維陣列,或6個元素的數組? – Barmar
6維數組。當我添加其他用戶時,它將被添加到數組中。謝謝 – joegyoung