title: php arrays: how to put given integers as key
body: <p>I need to give pre-defined integers as key for an array (I need the integer key, as this will be stored in an integer field in a database). I can specify strings as a key, but if I try to submit in integer, the array ignores my key specification and assigns outomaticalls 0,1,2, .. as key.</p>
  
  <p>Here my sample code</p>
  
  <pre><code>   public function TestArray ()
       { 
          $valuesForIndexOfArray = array(100,101,102);
          //$valuesForIndexOfArray = array('l','m','n','o','p');   // in this case the string values are used in the index
          $resultArray = array();
          foreach ($valuesForIndexOfArray as $singleIndexValue ){
              $dummyValue = "dummytext-".$singleIndexValue;      
              $indexOfResultArray = $singleIndexValue;
              //$indexOfResultArray = $indexOfResultArray." ";  // !!! only if made to string, singleAnswerId appears in index, otherwise autoindex 0,1,2,          
              $newElementForResultArray = array($indexOfResultArray =&gt; $dummyValue);  
              $resultArray = array_merge($resultArray, $newElementForResultArray);
          }
          return ($resultArray);
       }
  </code></pre>
  
  <p>If I run the code as above, i get ( with dump in symfony, twig)</p>
  
  <p><img src="https://i.stack.imgur.com/lQ5HU.png" alt="enter image description here"></p>
  
  <p>If I use //$indexOfResultArray = $indexOfResultArray." "; and make it a string I the index looks almost as it should - but as string, which does not help me</p>
  
  <p><img src="https://i.stack.imgur.com/cAgxN.png" alt="enter image description here"></p>