Using array_combine() to Merge Arrays as Keys and Values in PHP


Combine two arrays where one serves as keys and the other as values.

Source Code

$keys = ['a', 'b', 'c'];
$values = [1, 2, 3];
$combined = array_combine($keys, $values);
print_r($combined); // Outputs: Array ( [a] => 1 [b] => 2 [c] => 3 )
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments