ldap_count_entries

int ldap_count_entries(resource connectionID, int result) 

Counts returned entries.

Returns:

Number of entries; FALSE on error

Description:

Returns the number of entries found from performing a query with a search function such as ldap_read() or ldap_search(). Useful for looping through a result set.

Availability:

UNIX/Linux, Windows

Version:

3+, 4+

Example:

Obtain a count of results
$host = "ldap.foo.com"; 
$ldapconn = ldap_connect($host); 
$filter = "smith"; 
$result = ldap_search($ldapconn, "ou=People,dc=foo,dc=com", "cn=*$filter*"); 
$count = ldap_count_entries($ldapconn,$result); 
echo "Found $count entries matching $filter in the directory\n"; 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.