Jump to content

array_diff function


Hobbyist_PHPer

Recommended Posts

Hi everyone... I have one last last question, for now anyway :)

 

Ok, so I have 2 arrays with ProfileIDs in them, what I need to find are the ProfileIDs that are in both of them... From what I've researched, I can't find a PHP function that returns an array of keys or values from comparing more than one array...

 

Example array:

Array

(

    [3] => 3

    [4] => 4

    [8] => 8

)

Link to comment
https://forums.phpfreaks.com/topic/239025-array_diff-function/
Share on other sites

If you are looking to find the keys that are in both arrays, array_diff() is the exact opposite of what you want to use. Sounds like you will want to use array_intersect()

 

Thank you, didn't find that function... that worked...

Are you familiar with php.net

Will help you find useful functions and much more

Link to comment
https://forums.phpfreaks.com/topic/239025-array_diff-function/#findComment-1228158
Share on other sites

If you are looking to find the keys that are in both arrays, array_diff() is the exact opposite of what you want to use. Sounds like you will want to use array_intersect()

 

Thank you, didn't find that function... that worked...

Are you familiar with php.net

Will help you find useful functions and much more

 

Yeah, I am familiar, I actually find this place easier to use though, http://www.w3schools.com/PHP/php_ref_array.asp

Link to comment
https://forums.phpfreaks.com/topic/239025-array_diff-function/#findComment-1228159
Share on other sites

Not sure how serious you are with that website. I will admit they so have good tutorials. But they also have problems with their teachings. If you'd like to readinto what I am saying, visit http://www.w3fools.com

I post this for your learning

 

Actually use it quite often, but I do use php.net as well, but thanks for info, I'll check it out...

Link to comment
https://forums.phpfreaks.com/topic/239025-array_diff-function/#findComment-1228169
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.