merge multiple array into single php code example

Example 1: 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"
]

Example 2: php multiple array to single array

$array = array_column($array, 'plan'); 
// plan adalah nama kolom nya  
// $array adalah variable nya 
// semisal pengen membuat get data jadi single array bisa seperti ini 
     $CI = get_instance(); 
	 $DB1 = $CI->load->database('nama_db', TRUE);
	 $sql = "select dept from v_dept_distinct order by dept asc ";
	  $query=$DB1->query($sql);
	  // print_r(array_column($query->result_array() , 'dept')); 
	  return  array_column($query->result_array() , 'dept');