Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-31-2007, 10:56 AM   PM User | #1
NancyJ
Senior Coder

 
NancyJ's Avatar
 
Join Date: Feb 2005
Location: Bradford, UK
Posts: 3,162
Thanks: 19
Thanked 65 Times in 64 Posts
NancyJ will become famous soon enough
array functions

I've been going through the manual looking for a function but I can't find it but maybe someone here knows whether it exists and what it might be called.

I have 2 arrays, I want to reduce those arrays to a single array that only contains the values that exist in both arrays.
__________________
http://www.hazelryan.co.uk

Last edited by NancyJ; 08-31-2007 at 10:58 AM.. Reason: doh! found it the second I posted - array_intersect
NancyJ is offline   Reply With Quote
Old 08-31-2007, 12:36 PM   PM User | #2
daveyand
New Coder

 
Join Date: Jun 2007
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
daveyand is an unknown quantity at this point
i cant think of one off the top of my head, but writing something like this would be simple enough.

Just loop one of them and for each value do an in_array() on the other one, if thats true then popultate a new one.

Other than that, in the 5 seconds i've looked, no idea.
__________________
PHP / CSS / Perl / XML / XHTML

For cheap ipod touch go to protella.com
daveyand is offline   Reply With Quote
Old 08-31-2007, 12:49 PM   PM User | #3
Mwnciau
Regular Coder

 
Join Date: May 2006
Location: Wales
Posts: 820
Thanks: 1
Thanked 82 Times in 79 Posts
Mwnciau is on a distinguished road
array_intersect
Mwnciau is offline   Reply With Quote
Old 08-31-2007, 01:46 PM   PM User | #4
venkib097
Registered User

 
Join Date: Jul 2007
Posts: 20
Thanks: 3
Thanked 0 Times in 0 Posts
venkib097 is an unknown quantity at this point
use array_merge() function to combine two arrays.for more info visit http://www.w3schools.com/php/func_array_merge.asp

Last edited by venkib097; 08-31-2007 at 01:52 PM..
venkib097 is offline   Reply With Quote
Old 08-31-2007, 02:37 PM   PM User | #5
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
Quote:
Originally Posted by Mwnciau View Post
Winner
Inigoesdr is offline   Reply With Quote
Old 08-31-2007, 02:43 PM   PM User | #6
NancyJ
Senior Coder

 
NancyJ's Avatar
 
Join Date: Feb 2005
Location: Bradford, UK
Posts: 3,162
Thanks: 19
Thanked 65 Times in 64 Posts
NancyJ will become famous soon enough
Quote:
Originally Posted by Inigoesdr View Post
Winner
I'm the winner Post deleting has gone away again but I found the answer 2 minutes after posting
Quote:
Last edited by NancyJ : 08-31-2007 at 10:58 AM. Reason: doh! found it the second I posted - array_intersect
__________________
http://www.hazelryan.co.uk
NancyJ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 AM.


Advertisement
Log in to turn off these ads.