Example 1 — Building a Record From Two Lists
Combine a list of field names with a list of values.
<?php
$keys = ['name', 'age', 'city'];
$values = ['Asha', 28, 'Pune'];
print_r(array_combine($keys, $values)); How It Works
- $keys holds the three field names and $values holds three matching values.
- array_combine() pairs the items by position: first with first, second with second.
- 'name' gets 'Asha', 'age' gets 28 and 'city' gets 'Pune'.
- print_r() shows the final associative array.

