Link to home
Start Free TrialLog in
Avatar of Lennart Ericson
Lennart EricsonFlag for Sweden

asked on

How to delete values from an array using php

I have two arrays, $array_1 and $array_2.
If a value in $array_2 is also found in $array_1 it should be deleted from $array_1.
The same value might be found several times in both of the arrays. Is the value present in $array_2, regardless of number of appearances, it should be deleted from all appearances in $array_1.
Script language: php
What procedure do you recommend?
Avatar of Peos John
Peos John
Flag of Malaysia image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Only recommendation I would make over Peos John's reply is to rather use the resource as a reference. W3 Schools is ok but PHP.Net is the definitive source and has a wealth of other related information in the examples, topic posts and related function lists
No points for this, please, but I would add that sometimes the most useful part of the online PHP manual are the user-contributed notes in the function reference.  Examples:  <<< Especially this one!
Avatar of Lennart Ericson


Sorry for late reply.
Thanks so much. It worked very well.