I have two arrays:
$userBuildingIds
print_r():
Array
(
[0] => 4
)
and $allRequiredIds
print_r:
Array
(
[0] => 4
[1] => 1
)
now I want check if one element of $userBuildingIds exists in the $allRequiredIds array. And if so, I want get a new array of all elements they are NOT in the first array like this:
Array
(
[0] => 1
)
(because 1 isn't in $userBuildingIds)
I try this with array_diff but it gives me this result (with the key of array 2):
Array
(
[1] => 1
)
Is it possible to get an array in which are all the elements of array $allRequiredIds where are not in $userBuildingIds, but without copy the keys from $allRequiredIds?
array_values()on it to get a new array having the keys starting with0. So, the complete code will bearray_values(array_diff($allRequiredIds, $userBuildingIds)).$arr1 = [1,1,1,1,1]; $arr2 = [1,2]; array_diff($arr1, $arr2);will return emty array? that is really your point?