Answers for "merge multiple array into single 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
0

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');
Posted by: Guest on February-02-2021

Code answers related to "merge multiple array into single php"

Browse Popular Code Answers by Language