array('funcname' => DATA)) // so take the first element of the 'result' array $data = reset($data['result']); $first = reset($data); $single = ! is_array($first); $content = ''; if($single) { $content .= ""; } else { $content .= ''; foreach(array_keys($first) as $k) { $content .= ""; } $content .= ''; } $content .= ''; if($single) { foreach($data as $k => $v) { $content .= ""; } } else { foreach($data as $row) { $content .= ''; foreach($row as $col) { $content .= ''; } $content .= ''; } } $content .= '
FieldValue
$k
$k".print_r($v, true)."
'.print_r($col, true).'
'; return $content; } private function error($data) { $code = $data['error']['code']; $name = $data['error']['name']; $msg = $data['error']['reason']; return '

An error occured

'. "

[$code] $name

". "

$msg

"; } private function failure($data) { $code = $data['failure']['code']; $name = $data['failure']['reason']; return '

A failure occured

'. "

[$code] $name

"; } public function render($data) { $type = key($data); if (method_exists($this, $type)) { $content = call_user_func_array(array($this, $type), array($data)); } else { $content = '

Unable to render this

'; } echo $content; } }