[PHP] explode() an array and grep out a string

2004-02-07 Thread Bobby R . Cox
Hi all.

Is it possible to explode an array and have it exclude a certain 
string.   I currently have an array that is an ldapsearch that returns 
sub-accounts of a parent account. These accounts are then displayed so 
customer can either change the passwd or delete them.Thing is 
ldapsearch returns everymatch which includes the parent account, which 
is already listed on the page as the parent account.  I would like to 
eliminate the second listing of the parent account where the 
sub-accounts are listed.

This is where the array is collected:

$search = ldap_search($connection,dc=isp,dc=com, 
ispParentAcct=$sessUsername);

$entries = ldap_get_entries($connection, $search);
$num = $entries[count];
if ($num) {
$sessSubAccounts = ;
$i = 0;
while ($i  $num) {
$sessSubAccounts .= 
$entries[$i][uid][0] . |;
$i++;
}
}
One thing I would like to point out is that I did not have this problem 
before, but when I updated to a new version of openldap the following 
ldapsearch would no longer return the subaccounts:

$search = ldap_search($connection,dc=isp,dc=com, 
homeDirectory=/home/$sessUsername/*);

Any idea why that may be?

This is where the array is exploded:

?
   $i = 0;
 if ($sessSubAccounts) {

   $accounts = explode(|, $sessSubAccounts);

while ($i  count($accounts) - 1)
  ?
TIA

Bobby R. Cox
Linux Systems Administrator
Project Mutual Telephone
[EMAIL PROTECTED]
208.434.7185

Fix the problem,  not the blame.   

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] explode() an array and grep out a string

2004-02-07 Thread Adam Bregenzer
On Sat, 2004-02-07 at 03:09, Bobby R.Cox wrote:
 Is it possible to explode an array and have it exclude a certain 
 string.   I currently have an array that is an ldapsearch that returns 
 sub-accounts of a parent account. These accounts are then displayed so 
 customer can either change the passwd or delete them.Thing is 
 ldapsearch returns everymatch which includes the parent account, which 
 is already listed on the page as the parent account.  I would like to 
 eliminate the second listing of the parent account where the 
 sub-accounts are listed.

Try this:

$parent_account = 'parent_name';
$ldap_results = array('account1','account2','parent_name');
$results = array_diff($ldap_results, array($parent_account));

$results will now have only account1 and account2.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php