473,466 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

combine two arrays ldap_search results to give one array with uniquevalues?

Hi,

I'm doing an two ldap_search queries and I need to combine the two
results into one single array containing all the results from each but
removing duplicates.

I have tried built in php functions such as array_merge (which gives
me duplicates) and array_unique which does not work either.
Any ideas?

Thanks.
Nov 3 '08 #1
5 3582
On Sun, 2 Nov 2008 17:01:07 -0800 (PST), pt*******@googlemail.com
wrote:
Hi,

I'm doing an two ldap_search queries and I need to combine the two
results into one single array containing all the results from each but
removing duplicates.

I have tried built in php functions such as array_merge (which gives
me duplicates) and array_unique which does not work either.
Any ideas?

Thanks.
Yes, you can use array_diff(), which will look at the arrays' valus.
Note that the key associativity of the first array is maintained in
the return array.

<URL:http://php.net/array_diff>
--
Curtis
$email = str_replace('sig.invalid', 'gmail.com', $from);
Nov 3 '08 #2
That wont work. I need all the unique values from both arrays in one
array, not just the difference. but thanks...
Nov 3 '08 #3
Am Mon, 03 Nov 2008 04:19:02 -0800 schrieb macca:
That wont work. I need all the unique values from both arrays in one
array, not just the difference. but thanks...
have not done much php lately but does a combination of merge and unique
not work? something like this:

$arrRes= array_unique(array_merge($arr1,$arr2));

hope its not a stupid sugestion ... first try of use net by my side ...

cu
Nov 3 '08 #4
yes i have tried this to no avail but thanks for the suggestion
Nov 3 '08 #5
On Mon, 3 Nov 2008 04:19:02 -0800 (PST), pt*******@googlemail.com
wrote:
That wont work. I need all the unique values from both arrays in one
array, not just the difference. but thanks...
Again, just looking at values, perhaps this will do it:

$a = array(...);
$b = array(...);
$c = array_merge(array_diff($a,$b), array_diff($b,$a));

--
Curtis
$email = str_replace('sig.invalid', 'gmail.com', $from);
Nov 4 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sacs | last post by:
Hi all, this is _really_ bugging me, and the Google God has failed me: Doing an ldap_search of a Wink2k Active Directory trying to get the objectGUID. This is a unique id within AD and is meant...
8
by: frekster | last post by:
Hi. I used to be able to do this easily in vb 6 via looping and preserving the source array data/size etc. How can I do this in vb.net? I've been trying for a while now and this should be...
8
by: nescio | last post by:
hello, i have an array and i don't know the content of it, but i want only unique values. in php there is a function to do this, but how must i do this in javascript? i have tried a lot and...
0
by: Max | last post by:
Hi, I've got a web GUI in which users can add server IP, ldap base, username, password to enable connectivity to Active Directory. Everything works great in the connection, etc. However, if the...
3
by: Schroeder, AJ | last post by:
Hello group, I am a relative PHP newbie and I am trying to combine two arrays together, but I also need to keep the keys of one array intact. What I am doing is two SNMP walks against a Cisco...
0
by: Ward Germonpré | last post by:
Hi, ldap_search takes an array of attributes it is supposed to retrieve from AD. However the order in which the attributes are returned is not the same as the attributes in the array. Is...
2
by: chris | last post by:
I have a few byte arrays that I would like to combine into one array (order needs to be kept). What would be the most efficient way to do this? Thanks for your time, Chris
9
by: nico3334 | last post by:
Hi, I have 2 arrays (Each As a String), and I would like to combine these into a new single array. Is there an easy way of coding this? For example, I want "arrData" and "arrID" to be combined into...
6
by: Emiurgo | last post by:
Hi there to everyone! I've got a problem which may be interesting to some of you, and I'd be very grateful if there is someone who can give me some advice (or maybe redirect me to some other place)....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.