I have two arrays which I am comparing. The comparison is working perfectly as follows:
$tmp = array_diff_key($arr1, $arr2);
$echo $tmp;
However, I only want to display the values that exist in array 2 that don't exist in array 1.
Edit: Ok so thank for everyone's help. How ever I am still unable to make it work.
I am now using
$tmp = array_diff($arr2, $arr1);
var_dump($tmp);
which prints out the following:
array(1) { [0]=> array(3) { [0]=> string(4) "cars" [1]=> string(4) "vans" [2]=> string(6) "people" } }
So, I'll explain a little.
Array 1 has cars, vans (this is pulled from the database).
Array 2 has cars, people (this is entered from a form).
I'm trying to only show values that are not in the database so I thought $tmp would echo just people as cars is in the database and vans is in $arr1
I hope thats clear as its even confusing me writing it ;)
If I var_dump both array individually I get
array(3) { [0]=> NULL [1]=> string(4) "cars" [2]=> string(4) "vans" } array(1) { [0]=> array(2) { [0]=> string(6) "people" [1]=> string(5) "tanks" } }
$echoshould beechoand this won't print the contents of arrays anyway.