Assigning values from a numerical array to an associative array I have this function here:

&lt;?php
public function assignData($data)
{
    $aSqlData['company'] = $data[0];
    $aSqlData['tx_trouserextend_contactperson'] = $data[1];
    $aSqlData['username'] = $data[2];
    $aSqlData['tx_trouserextend_commission'] = $data[3];
    $aSqlData['tx_trouserextend_wincap_version'] = $data[4];
    $aSqlData['tx_trouserextend_wincap_link'] = $data[5];
    $aSqlData['tx_trouserextend_contract_due'] = $data[6];
    $aSqlData['tx_trouserextend_pos_version'] = $data[7];
    $aSqlData['tx_trouserextend_pos_link'] = $data[8];
    $aSqlData['tx_trouserextend_quick_select_version'] = $data[9];
    $aSqlData['tx_trouserextend_quick_select_link'] = $data[10];
    $aSqlData['password'] = $data[11];

    $this-&gt;userdata = $aSqlData;
}


This goes on for like 10 more items with this way of assigning. Is there maybe a better way to iterate through it? For instance, just adding the indices and run assign every numerical index to the corresponding associative array-key?

Even though it works, it is not that nice to maintain, imho. Ideas how to improve this? As you can imagine, if the csv-file grows and gets more fields, I'd have to add a line of code for every new column. Thought there would/could be a better way.
This has been answered here: https://stackoverflow.com/a/3000342/561731 

array_combine

In your case:

$this-&gt;userdata = array_combine(['company','tx_trouserextend_contactperson',...], $data);


Can also just have anarray of $keys to match to your data and then use array_combine