title: Why cant i change my array value? But if i add address pointer to array, it works
body: <p>I have a code block to return as a json as follow;</p>
  <pre><code>    $data = $this-&gt;regionRepository-&gt;getDistrictsByGivenTravelTag();//returns an array
  
      foreach ($data as $city){
          $city[&quot;is_fav&quot;] = false;
          if(auth()-&gt;user()){
              /** city */
              $fav_cities = auth()-&gt;user()-&gt;favoriteCities-&gt;pluck(&quot;id&quot;);
  
              if(in_array($city[&quot;city_id&quot;],$fav_cities-&gt;toArray())){
                  $city[&quot;is_fav&quot;] = true;
              }
          }
      }
  
      dd($data);
  </code></pre>
  <p>This code block shows it without &quot;is_fave&quot;. But I want to add &quot;is_fav&quot; key. Therefore,
  I added address pointer to my array inside the foreach as follow;</p>
  <pre><code>foreach ($data as &amp;$city){
      ...
  }
  dd($data);
  </code></pre>
  <p>And now it works, so &quot;is_fav&quot; key has been added.</p>
  <p>Could you explain why it's necessary?</p>