R4R Team working to provide free of cost for experienced and freshers

Tutorials | Examples|Interview Questions and Answers|Java Tutorials| C Tutorials | C++ Tutorials | Spring Tutorials| Hibernate Tutorials | JSP Tutorials | Servelets Tutorials| C# Tutorials | PHP Tutorials etc , Basics | Download Software | Data Types | Variables | Constant | Storage & Classes | Operators | Decisions Making | Loops | Functions| Numbers | Arrays | Pointers | String | Datastructure | Expressions | Preprocessor Statement | I/O | Exception Handling | OOPs Tutorial | Classes and object |C++ Inheritance Overloading | Polymorphism | Abstraction | Encapsulation | Interfaces | Multithreading etc

PHP Programing language

array_combine() Function in PHP
Previous Home Next

array_combine()

The array_combine() function creates an array by using the elements from one "keys" array and one "values" array.

Syntax:
array_combine(keys,values);

In above syntax, "keys" are array of keys and "values" are array of values.

Example:

<?php
$fruit_name=array("Apple","Banana","Mango");
$fruit_weight=array("5kg","3kg","10kg");
$Total=array_combine($fruit_name,$fruit_weight);
print_r($Total);
?>

Output:

Array ( [Apple] => 5kg [Banana] => 3kg [Mango] => 10kg )

Previous Home Next