title: How to add data to specific index of an array
body: <p>I have an array which contains usernames, which I have created by using array_push to add each item in a foreach loop to the array:</p>
  
  <pre><code>array(4) {
    [0]=&gt;
    string(13) "Username1"
    [1]=&gt;
    string(10) "Username2"
    [2]=&gt;
    string(12) "Username3"
    [3]=&gt;
    string(11) "Username4"
  }
  </code></pre>
  
  <p>I also have an ID number stored in <code>$id</code></p>
  
  <p>How can I change the array so that it stores both the <code>username</code> and <code>ID</code> nested together in the array? Or if not that way, what's the best way to keep these two items of data associated in the array?</p>
  
  <p>This is the code to create the array <code>$accounts_list</code> which currently only stores the username.</p>
  
  <pre><code>$all_accounts = [];
     foreach ($accounts_list as &amp;$account) {
        $name = $account['name'];
        array_push($all_accounts,$name);
  
        $id = $account['id'];
     }
  </code></pre>