PHP - array_combine() Function Example

03-Apr-2023

.

Admin

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....

#PHP 8

#PHP