|
|
Php Array Elements Combine Function
|
Tutorials » Php »
|
Topic |
What is array_combine Function?
|
|
Explanation |
|
The "array_combine" function is used to create an array by using one array for keys and another for its values.
Syntax:
array_combine(keyarray,valarray)
In the above syntax "keyarray" specify the keys of an array and "valarray" the values of an array.
Example
<?php
$a = array('1', '2', '3');
$b = array('one', 'two', 'three');
$c = array_combine($a, $b);
?>
Result:
Array ( [1] => one [2] => two [3] => three )
In the above example, the keys as elements in the array $a is combined with valuesas elements in the array $b, to display the array elements.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|