multiple array in php code example
Example 1: in array php multiple values
$haystack = array(...);
$target = array('foo', 'bar');
if(count(array_intersect($haystack, $target)) == count($target)){
// all of $target is in $haystack
}
if(count(array_intersect($haystack, $target)) > 0){
// at least one of $target is in $haystack
}
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');