I am trying to create an array as a result of comparing 2 arrays: the 1st array has more elements, such as:
array1: { 0 => "car1" 1 => "car2" 2 => "car3" 3 => "car4" 4 => "car5" }
and the second array does not have all the elements:
array2: { 0 => "car1" 1 => "car4" 2 => "car5" }
So, there are all possible categories (array1) and categories assigned by post (array2) (this is a WordPress thing).
I try to compare these arrays (but not with the array_diff() function, which led to the value of the elements instead of boolean) and get the result as true / false. Therefore, I want to compare all the values ββof arrays and generate an array map, or perhaps use the array_combine() function to get such an array:
result_array: { "car1": true, "car2": false, "car3": false }
etc....
To output an array, it is important to have all categories and their results (true, false) for the message.
Is there an easy way to do this, or maybe this is a function that I could use?
arrays php wordpress
Luqsus
source share