php8.5
Home/ Manual/ ldap / functions/ ldap_count_entries

ldap_count_entries

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Count the number of entries in a search

Description

ldap_count_entries(LDAP\Connection $ldap, LDAP\Result $result): int

Returns the number of entries stored in the result of previous search operations.

Parameters

ldap

Ldap

result

Result

Return Values

Returns the number of entries in the result, or -1 on error.

Changelog

VersionDescription

Examples

ldap_count_entries() example

Retrieve number of entries in the result.

php
     // $ds is a valid LDAP\Connection instance for a directory server

     $dn        = 'ou=example,dc=org';
     $filter    = '(|(sn=Doe*)(givenname=John*))';
     $justthese = array('ou', 'sn', 'givenname', 'mail');

     $sr = ldap_search($ds, $dn, $filter, $justthese);

     var_dump(ldap_count_entries($ds, $sr));
     

The above example will output something similar to:

output
     int(1)
     

Source: reference/ldap/functions/ldap-count-entries.xml · from the official PHP manual (php/doc-en)