title: Is there an easy way to find the index of a newly created array item using bracket notation in PHP?
body: <p>I am working with a script that I am iterating through an array and assigning values in that array to another array. I need the index of the newly created array item so I can manipulate it further. When you create a new item in an array using the <code>$array[] =</code> method is there an easy way to determine what index was assigned without looping through the array and evaluating or using array_search?</p>
  
  <p><strong><em>Current Code</em></strong></p>
  
  <pre><code>foreach($array1 as $item) {
     $array2[] = $item['some_index'];
  }
  </code></pre>
  
  <p><strong><em>Only solution I've found so far, but seems clunky</em></strong></p>
  
  <pre><code>foreach($array1 as $item) {
     $array2[] = $item['some_index']; //has a value of 'value1'
     $key = array_search('value1',$array2)
  }
  </code></pre>