fork(1) download
  1. <?php
  2.  
  3. $array = [
  4. [100, 'A', 99.9],
  5. [200, 'B', 88.8],
  6. [300, 'C', 77.7],
  7. ];
  8.  
  9. $keys = ['code', 'name', 'count'];
  10.  
  11. foreach ($array as $index => $item) {
  12. $array[$index] = array_combine($keys, $item);
  13. }
  14.  
  15. var_dump($array);
  16.  
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
array(3) {
  [0]=>
  array(3) {
    ["code"]=>
    int(100)
    ["name"]=>
    string(1) "A"
    ["count"]=>
    float(99.9)
  }
  [1]=>
  array(3) {
    ["code"]=>
    int(200)
    ["name"]=>
    string(1) "B"
    ["count"]=>
    float(88.8)
  }
  [2]=>
  array(3) {
    ["code"]=>
    int(300)
    ["name"]=>
    string(1) "C"
    ["count"]=>
    float(77.7)
  }
}