I have 2 arrays:
$array_1 = [1,2,3,1,2];
and:
$array_2 = [0,0,0,0,0];
I want to change the values of $array_2, so it will show if the element in $array_1 is number 1 or 2 only.
foreach($array_1 as $item)
{
if($item = 1 || $iten == 2)
{
$index = ...;//how to get index of this element
$array_2[$index] = 1; //I don't sure this syntax is right
}
}
Output $array_2 should look like: $array_2 = [1,1,0,1,1]