Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5928367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:17:02+00:00 2026-05-22T14:17:02+00:00

I have a ldap request that returns an array, however the returned array is

  • 0

I have a ldap request that returns an array, however the returned array is full of “counts” and odd pointers, as this application is an API designed to be used with Javascript on mobile devices, the less text there is the better.

What is the most efficient way to strip out all the values that don’t have the key count? As well as the ones that just seem to be saying what the keys are (eg [0] => cn)?

Array
(
    [status] => OK
    [count] => 4
    [results] => Array
        (
            [count] => 3
            [0] => Array
                (
                    [cn] => Array
                        (
                            [count] => 1
                            [0] => James Bee
                        )

                    [0] => cn
                    [umanprimaryou] => Array
                        (
                            [count] => 1
                            [0] => Awesome School
                        )

                    [1] => umanprimaryou
                    [ou] => Array
                        (
                            [count] => 2
                            [0] => School of Awesome
                            [1] => Faculty of Engineering
                        )
etc...

Aiming for

Array
(
    [status] => OK
    [results] => Array
        (
            [0] => Array
                (
                    [cn] => Array
                        (
                            [0] => James Bee
                        )
                    [umanprimaryou] => Array
                        (
                            [0] => Awesome School
                        )
                    [ou] => Array
                        (
                            [0] => School of Awesome
                            [1] => Faculty of Engineering
                        )
etc...

For further explanation I am wanting to unset all the [count] => value pairs and if possible the values such as [0] => cn in the results array.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:17:03+00:00Added an answer on May 22, 2026 at 2:17 pm

    Untested code:

    function strip_count(array $arr) {
        foreach ($arr as $key => $value) {
            if (is_array($arr[$key])) {
                strip_count($arr[$key]);
            } else {
                if ($key == 'count') {
                    unset($arr[$key]);
                }
            }
        }
    }
    

    Edit: I wrote this before you edited your question, but it shouldn’t be too hard to modify this recursive function to strip out the other things you wish to remove as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET application that authenticates users using Ldap against active directory. This
I have a slapd LDAP server which is critical to my application. I want
I have a Java app that can authenticate to LDAP by logging users into
I have to implement LDAP authentication with eDirectory in Java application. I guess some
I have a web application (PHP, but doesn't matter). It uses LDAP for authentication
I recently encountered an odd problem with RSACryptoServiceProvider.VerifyHash . I have a web application
I have an Ldap directory synchronised from a microsoft active directory. This Ldap contain
We have LDAP 5.2 running so that it checks your password against a dictionary
I have uncommented the LDAP and UserMapper connectors in application.xml I know my LDAP
We are looking at building an application that either proxies a standalone LDAP server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.