array_combine

It creates an array by using one array for keys and another for its values

Example

<?php
echo “<pre>”;
$array1 = array(‘PHP’, ‘ASP’, ‘JSP’);
$array2 = array(‘Javascript’, ‘VBScript’, ‘ActionScript’);
$array3 = array_combine($array1, $array2);
print_r($array3);
?>

Output

Array
(
[PHP] => Javascript
[ASP] => VBScript
[JSP] => ActionScript
)

Share