dadamssg Posted August 12, 2009 Share Posted August 12, 2009 i have two arrays that hold numerical values. I want to end up with one array that only has values that BOTH arrays have in common. How would i go about doing this? Quote Link to comment https://forums.phpfreaks.com/topic/169867-solved-combine-arrayssort-of/ Share on other sites More sharing options...
Philip Posted August 12, 2009 Share Posted August 12, 2009 array_intersect perhaps? Quote Link to comment https://forums.phpfreaks.com/topic/169867-solved-combine-arrayssort-of/#findComment-896151 Share on other sites More sharing options...
dadamssg Posted August 12, 2009 Author Share Posted August 12, 2009 that seems like what i need but sometimes my arrays won't have values...that sounds really weird. I'm using the results of two different queries to then use in another query. Sometimes the results of the queries pulls up nothing so i get an error with this function saying that arrays i inputted aren't arrays.... Quote Link to comment https://forums.phpfreaks.com/topic/169867-solved-combine-arrayssort-of/#findComment-896165 Share on other sites More sharing options...
.josh Posted August 12, 2009 Share Posted August 12, 2009 so use a condition to see if a result is returned. If so, use the function. If not, do something else. For instance, initialize it as an array if no results returned, so that array_intersect won't throw an error. Quote Link to comment https://forums.phpfreaks.com/topic/169867-solved-combine-arrayssort-of/#findComment-896166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.