<?php
if(!function_exists('is_assoc')){
function is_assoc($array) {
return (bool)count(array_filter(array_keys($array), 'is_string'));
}
}
/**
* getCols
*
* Takes an array of associative arrays and combines them to get
* the columns
*
* @author Joe Richardson
* @access public
* @return object Instance of DB or Null
*/
function getCols(array $data)
{
if(is_assoc($data)){
return $data;
}else{
return (array)call_user_func_array('array_merge_recursive',$data);
}
}
$a = array(
array( 'id' => 1
, 'name' => 'foo'
, 'date' => time()
)
, array( 'id' => 2
, 'name' => 'bar'
, 'date' => time()
)
, array( 'id' => 3
, 'name' => 'george'
, 'date' => time()
)
, array( 'id' => 4
, 'name' => 'burdell'
, 'date' => time()
)
);
$b = getCols($a);
var_dump($b);
preferences:
34.35 ms | 402 KiB | 5 Q