Hello friends,
If you want to combine 2 arrays in which 1 is used as a key and another as value then you can use a predefined PHP function which is "array_combine". array_combine function creates an array by using one array for keys and another for its values.
Here is an example which is explaining this-
<?php
$a = array('key1', 'key2', 'key3');
$b = array('value1', 'value2', 'value3');
$c = array_combine($a, $b);
print_r($c);
?>
Output:
Array
(
[key1] => value1
[key2] => value2
[key3] => value3
)
0 Comment(s)