Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare the values of two arrays

Status
Not open for further replies.

misslois74

Programmer
Sep 27, 2008
63
PH
im working on a script right now where in i would need to compare values of one array with another values from another array how will i go about the script for these.... thanks in advance.
 
Well that's going to depend on exactly how you want to compare them?

This would check whether or not a value from one array exists in another, and if it doesn't it puts the value in a third array.

Code:
$array_difference=array_diff($array_one,$array_two);

However I'm not sure if that is what you want.





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
there are a bunch of array functions that i find i never use. probably to my detriment. i'm never _quite_ sure how these abstracted functions (like array_diff) might work on edge cases. I'm sure they work fine and i should take the time, but somehow I always end up using something like a foreach loop with an empty, isset or in_array function in each loop iteration. Far from optimised compared with a pre-compiled alternative, but at least i know that they will work the way i want.
 
well, actually what im trying to do is compare the field values from two tables, here is the scenario: i have a table which lists all the categories and another table which lists all the categories which is dynamically selected by a user now what i would like to happen is on the front end if a category is already listed the link for that category should be deactivated, any suggestion on how will i go about this?
 
personally i didn't understand the explanation.
 
thanks! for all the responses i have figured it out what to do with the problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top