I want to compare the values of two flat, indexed arrays and generate a new array where the keys are the original values from the first array and the values are boolean values indicating whether the same value occurred in both origibal arrays.
$array1 = [
"car1",
"car2",
"car3",
"car4",
"car5"
];
$array2 = [
"car1",
"car4",
"car5"
}
I tried to compare the arrays with the array_diff()
function but it gave me elements values instead of boolean values.
I want to compare each value from the two arrays and generate an "array map" or maybe using the array_combine()
function to get array like this:
[
"car1" => true,
"car2" => false,
"car3" => false
"car4" => true,
"car5" => true,
]