Hobbyist_PHPer Posted June 11, 2011 Share Posted June 11, 2011 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 More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 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() Link to comment https://forums.phpfreaks.com/topic/239025-array_diff-function/#findComment-1228154 Share on other sites More sharing options...
Hobbyist_PHPer Posted June 11, 2011 Author Share Posted June 11, 2011 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... Link to comment https://forums.phpfreaks.com/topic/239025-array_diff-function/#findComment-1228155 Share on other sites More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 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 More sharing options...
Hobbyist_PHPer Posted June 11, 2011 Author Share Posted June 11, 2011 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 More sharing options...
fugix Posted June 11, 2011 Share Posted June 11, 2011 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 Link to comment https://forums.phpfreaks.com/topic/239025-array_diff-function/#findComment-1228161 Share on other sites More sharing options...
Hobbyist_PHPer Posted June 11, 2011 Author Share Posted June 11, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.