Remove values in array2 from array1


Posted on 16th Feb 2014 07:03 pm by admin

I have two arrays.

Array 1 is where the array key holds various different numbers. For example:
Code: [Select]$array[32] = 1;
Did you know?Explore Trending and Topic pages for more stories like this.
$array[122] = 1;
$array[238] = 1;
$array[324] = 1;

The other array holds values in the same way (but may have less values in total):
Code: [Select]$array[238] = 1;
$array[287] = 1;

I want to simply remove any values in array 2 from array 1 (so now array 1 simply holds 32, 122 and 324).

I am sure there is a quick array command that does this - so I won't need to use a foreach loop.
No comments posted yet

Your Answer:

Login to answer
143 Like 34 Dislike
Previous forums Next forums
Other forums

Form validation with functions
Hi there

I am trying to make a very simple form validation function. I currently have the fol

Loops and Classes
I am making a template system and everything seems to be going well up until I have to loop in a var

How to make URL loads only on login
On my page, when a user login he's redirects to user_home.php. I made it also to open the chat scree

function not returning the correct value
I have a program that needs to return a value from a function. I have an output statement inside the

Deleted Delivery but material wont return
We deleted a delivery but the material its still pending.

We made a reverse goods movemen

PHP and SMS
Hi all forum members. I am new here and am unsure what category shoild I post this in.
Moderator

Unifying logins of two different scripts
I have two different game scripts which I want to embed on my own site. The problem is I don't want

Using system() and bringing back the results
I am aware that you can use system() within PHP to execute system commands, but I was wondering if t

Create multiple (n) arrays
Hi there,

I have the following need:

I have 2 arrays (coming from a databases)

foreach result into a single variable
Hi,

I have this code...

Code: [Select]foreach ($_POST['Interests'] as $interest =&

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash