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);
?>
[
"color" => "green"
"color" => "red",
"color" => "blue"
]
Example 2: php multiple array to single array
$array = array_column($array, 'plan');
$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);
return array_column($query->result_array() , 'dept');