Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

PHP array_combine() Function

by
Category:php
php php array function
PHP array_combine() Function

The array_combine() function is used to creates an array by using one array for keys and another for its values.

It returns the combined array, FALSE if the number of elements for each array isn't equal or if the arrays are empty.

Parameter Description
keys Required. Array of keys
values Required. Array of values

Syntax

 array_combine(keys,values); 

Example

$firstname = array("Prince","James","Samuel");
$nickname =array("Alex","Lachlan","Cooper");
$array =array_combine($firstname,$nickname);
print_r($array);

Output

Array ( 
        [Prince] => Alex 
        [James] => Lachlan  
        [Samuel] => Cooper 
) 

0 Comments


Html code work in comment box


Related Post