note 59185 added to function.ldap-modify
| From: | jmw1982 at gmail dot com | Date: | Mon, 28 Nov 2005 22:03:59 +0000 |
| Subject: | note 59185 added to function.ldap-modify | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-99266@lists.php.net to get a copy of this message | ||
If you're writing a multiple values for an attribute with ldap_modify (), the function will
attempt to write all entries in the value array even if those entries are blank. Setting blank
entries to a blank array in the manner used for attribute deletion, ie:
$attributes[$attr_name][3] = array ();
results in the string "Array" being written to the directory for that value. The only way
I was able to find to do what I wanted - only write the values for the attribute that were submitted
on the form - was to check if each attribute had multiple values and unset () blank values, eg:
foreach ($attributes as $key => $cur_val) {
if ($cur_val== '') {
$attributes[$key] = array ();
}
if (is_array ($cur_val)) {
foreach ($cur_val as $mv_key => $mv_cur_val) {
if ($mv_cur_val == '') {
unset ($attributes[$key][$mv_key]);
}
else {
$attributes[$key][$mv_key] = $mv_cur_val;
}
}
}
}
----
Manual Page -- http://www.php.net/manual/en/function.ldap-modify.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59185
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59185&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59185&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59185&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59185&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59185&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59185&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59185&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59185&report=yes
Search -- http://master.php.net/manage/user-notes.php