Answers for "array combine in php"

PHP
2

array_combine function in php

/* Array_combine is inbuilt function in php, which is use to combine two array in key value pair */
/* make sure both array should be of same length */

<?php
$fname=array("Peter","Ben","Joe");
$age=array("35","37","43");

$c=array_combine($fname,$age);
print_r($c);
?>

/*
Output:
Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
*/
  
/*
I hope it will help you.
Namaste
Stay home stay safe
*/
Posted by: Guest on May-28-2020
5

php combine arrays

$output = array_merge($array1, $array2);
Posted by: Guest on June-03-2020

Browse Popular Code Answers by Language