To compare two arrays containing the guid?

Hello!
Have two arrays:
$arr1 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2","97baa061-4208-4aeb-8136-eb76c0932a3d");

$arr2 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2");


Detailed array:
Array
(
 [0] => 090e3016-a593-11e4-8277-94de8067e7c4
 [1] => 090e3018-a593-11e4-8277-94de8067e7c4
 [2] => 090e301a-a593-11e4-8277-94de8067e7c4
 [3] => 090e301e-a593-11e4-8277-94de8067e7c4
)
second array:
Array
(
[22] => c7b8bdb2-a592-11e4-8277-94de8067e7c4
 [23] => c7b8bdb4-a592-11e4-8277-94de8067e7c4
 [24] => c7b8bdb8-a592-11e4-8277-94de8067e7c4
 [25] => c7b8bdba-a592-11e4-8277-94de8067e7c4
 [26] => c7b8bdc2-a592-11e4-8277-94de8067e7c4
 [27] => 090e3016-a593-11e4-8277-94de8067e7c4
 [28] => 090e3018-a593-11e4-8277-94de8067e7c4
)


You want to choose a divergence of tracts, but why the function array_diff, throws, breaks a value, individually, in General it does not work correctly.
How to compare arrays?
July 8th 19 at 12:10
3 answers
July 8th 19 at 12:12
Solution
$arr1 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2","97baa061-4208-4aeb-8136-eb76c0932a3d");
$arr2 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2");
var_dump(array_diff($arr1, $arr2));


array (size=1)
 1 => string '97baa061-4208-4aeb-8136-eb76c0932a3d' (length=36)


$arr1 = array(
 0 => '090e3016-a593-11e4-8277-94de8067e7c4',
 1 => '090e3018-a593-11e4-8277-94de8067e7c4',
 2 => '090e301a-a593-11e4-8277-94de8067e7c4',
 3 => '090e301e-a593-11e4-8277-94de8067e7c4',
);

$arr2 = array(
 22 => 'c7b8bdb2-a592-11e4-8277-94de8067e7c4',
 23 => 'c7b8bdb4-a592-11e4-8277-94de8067e7c4',
 24 => 'c7b8bdb8-a592-11e4-8277-94de8067e7c4',
 25 => 'c7b8bdba-a592-11e4-8277-94de8067e7c4',
 26 => 'c7b8bdc2-a592-11e4-8277-94de8067e7c4',
 27 => '090e3016-a593-11e4-8277-94de8067e7c4',
 28 => '090e3018-a593-11e4-8277-94de8067e7c4',
);
var_dump(array_diff($arr1, $arr2));


array (size=2)
 2 => string '090e301a-a593-11e4-8277-94de8067e7c4' (length=36)
 3 => string '090e301e-a593-11e4-8277-94de8067e7c4' (length=36)

Why not satisfied?
Array
(
[0] => 090e3016-a593-11e4-8277-94de8067e7c4
[1] => 090e3018-a593-11e4-8277-94de8067e7c4
[2] => 090e301a-a593-11e4-8277-94de8067e7c4
[3] => 090e301e-a593-11e4-8277-94de8067e7c4
)
second array:
Array
(
[22] => c7b8bdb2-a592-11e4-8277-94de8067e7c4
[23] => c7b8bdb4-a592-11e4-8277-94de8067e7c4
[24] => c7b8bdb8-a592-11e4-8277-94de8067e7c4
[25] => c7b8bdba-a592-11e4-8277-94de8067e7c4
[26] => c7b8bdc2-a592-11e4-8277-94de8067e7c4
[27] => 090e3016-a593-11e4-8277-94de8067e7c4
[28] => 090e3018-a593-11e4-8277-94de8067e7c4
) - Lavonne_Cass commented on July 8th 19 at 12:15
: updated the answer, everything seems correct, no? - nicklaus.Will commented on July 8th 19 at 12:18
Thanks, the problem is not in function, in 1C! - Lavonne_Cass commented on July 8th 19 at 12:21
: not at all) - nicklaus.Will commented on July 8th 19 at 12:24
July 8th 19 at 12:14
array_diff is exactly the function that you need:
<?php

$arr1 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2","97baa061-4208-4aeb-8136-eb76c0932a3d");

$arr2 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2");

print_r(array_diff($arr1, $arr2));</code-->
br><br> gives the result:<br><br><pre><code>Array ( [1] => 97baa061-4208-4aeb-8136-eb76c0932a3d )</code></pre><br><br> maybe the problem is somewhere else?
Updated input data - Lavonne_Cass commented on July 8th 19 at 12:17
July 8th 19 at 12:16
$arr1 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2","97baa061-4208-4aeb-8136-eb76c0932a3d", "111");
$arr2 = array( "45ebdbaa-380b-483b-80a2-73d7c53088e2", "222");
$result = array_merge(array_diff($arr1, $arr2), array_diff($arr2, $arr1));
var_dump($result);
/*
array(3) {
 [0] =>
 string(36) "97baa061-4208-4aeb-8136-eb76c0932a3d"
 [1] =>
 string(3) "111"
 [2] =>
 string(3) "222"
}
*/

Find more questions by tags PHPArrays