title: How to get and change value of element array in Laravel?
body: <p>I have 2 arrays: </p>
  
  <p><code>$array_1 = [1,2,3,1,2];</code></p>
  
  <p>and:</p>
  
  <p><code>$array_2 = [0,0,0,0,0];</code></p>
  
  <p>I want to change the values of <code>$array_2</code>, so it will show if the element in <code>$array_1</code> is number 1 or 2 only.</p>
  
  <pre><code>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  
      }
  }
  </code></pre>
  
  <p>Output <code>$array_2</code> should look like: <code>$array_2 = [1,1,0,1,1]</code></p>