Answers for "how to add two arrays together php"

PHP
4

php merge 2 arrays

<?php
  $array1 = [
      "color" => "green"
  ];
  $array2 = [
      "color" => "red", 
      "color" => "blue"
  ];
  $result = array_merge($array1, $array2);
?>

// $result
[
    "color" => "green"
    "color" => "red", 
    "color" => "blue"
]
Posted by: Guest on May-01-2020
1

php combine values of two arrays

$all_arrays = array_merge($array1, $array2, $array3, ...);
Posted by: Guest on October-31-2020

Code answers related to "how to add two arrays together php"

Browse Popular Code Answers by Language