PHP - array_combine() Function Example
Hello Friends,
In this blog, I will show you example of array combine function in php with example. We will talk about how to combine array in php.The array_combine() is an inbuilt function in PHP which is used to combine two arrays and create a new array by using one array for keys and another array for values. That is all elements of one array will be the keys of new array and all elements of the second array will be the values of this new array.
Here i will give you full example for how you can check array_combine() function in php file.
Syntax
array_combine(keys, values)
Example
<!DOCTYPE html>
<html>
<head>
<title>Php - How to check array_combine() function in php - NiceSnippets.com?</title>
</head>
<body>
<?php
$fname=array("Bca","B.com","Bsc");
$age=array("35","37","43");
$c=array_combine($fname,$age);
print_r($c);
?>
</body>
</html>
Output:
Array ( [Bca] => 35 [B.com] => 37 [Bsc] => 43 )
It will help you....
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example