array_combine

array_combine

array_combine

array_combine

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

Syntax:

array array_combine ( array keys, array values )

It returns an array by using the values from the keys array as keys and the values from the values array as the

corresponding values.

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

Example:

$a = array(’one’, ‘two’, ‘three’);
$b = array(’1′, ‘2′, ‘3′);
$c = array_combine($a, $b);

print_r($c);

The content in the array $c is

Array
(
[one]  => 1
[two]    => 2
[three] => 3
)

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.