47 var $look_for_leading_tabs = TRUE;
51 var $key_bg_color =
'1E32C8';
52 var $value_bg_color =
'DDDDEE';
53 var $fontsize =
'8pt';
54 var $keyalign =
'center';
55 var $fontfamily =
'Verdana';
57 var $show_object_vars;
58 var $export_dumper_path =
'http://tools.www.mdc.xmc.de/print_a_dumper/print_a_dumper.php';
69 $this->export_hash = uniqid(
'');
95 function print_a ($array, $iteration = FALSE, $key_bg_color = FALSE)
98 $key_bg_color = $this->key_bg_color;
101 if (!$iteration && isset($this->export_flag)) {
102 $this->output .=
'<form id="pa_form_'.$this->export_hash.
'" action="'.$this->export_dumper_path.
'?mode='.$this->export_flag.
'" method="post" target="_blank"><input name="array" type="hidden" value="'.htmlspecialchars(serialize($array)).
'"></form>';
107 $tmp_key_bg_color =
'';
108 for ($i = 0; $i < 6; $i += 2) {
109 $c = substr($key_bg_color, $i, 2);
115 $tmp_key_bg_color .= sprintf(
"%02X", $c);
117 $key_bg_color = $tmp_key_bg_color;
121 $this->output .=
'<table style="border:none;" '.(!$iteration && $this->export_flag ?
'onClick="document.getElementById(\'pa_form_'.$this->export_hash.
'\').submit();
" )' : '').'>'; 122 foreach ($array as $key => $value) { 123 $value_style = 'color:black;'; 124 $key_style = 'color:white;'; 126 $type = gettype($value); 128 // change the color and format of the value 134 $value_style = 'color:green;'; 138 $value_style = 'color:red;'; 142 $value_style = 'color:blue;'; 146 $value_style = 'color:darkblue;'; 150 if ($this->look_for_leading_tabs && preg_match('/^\t/m', $value)) { 151 $search = ['/\t/', "/\n/
"]; 152 $replace = [' ','<br />']; 153 $value = preg_replace($search, $replace, htmlspecialchars($value)); 154 $value_style = 'color:black;border:1px gray dotted;'; 156 $value_style = 'color:black;'; 157 $value = nl2br(htmlspecialchars($value)); 163 $key_style = 'color:#FF9B2F;'; 167 $this->output .= '<tr>'; 168 $this->output .= '<td nowrap align="'.$this->keyalign.'" style="background-color:#
'.$key_bg_color.';
'.$key_style.';font:bold
'.$this->fontsize.' '.$this->fontfamily.';
" title="'.gettype($key).'[
'.$type.']
">'; 169 $this->output .= $key; 170 $this->output .= '</td>'; 171 $this->output .= '<td nowrap="nowrap
" style="background-color:#
'.$this->value_bg_color.';font:
'.$this->fontsize.' '.$this->fontfamily.'; color:black;
">'; 174 if ($type == 'array') { 176 $this->print_a($value, TRUE, $key_bg_color); 178 $this->output .= '<div style="color:blue;
">Array (empty)</div>'; 180 } elseif ($type == 'object') { 181 if ($this->show_object_vars) { 182 $this->print_a(get_object_vars($value), TRUE, $key_bg_color); 184 $this->output .= '<div style="'.$value_style.'">OBJECT - '.get_class($value).'</div>'; 187 $this->output .= '<div style="'.$value_style.'" title="'.$type.'">'.$value.'</div>'; 190 $this->output .= '</td>'; 191 $this->output .= '</tr>'; 193 $this->output .= '</table>'; 198 * \brief helper function.. calls print_a() inside the printAClass 200 * \param array $array 202 * \param boolean $return_mode false 204 * \param boolean $show_object_vars false 206 * \param boolean $export_flag false 208 function print_a ($array, $return_mode = FALSE, $show_object_vars = FALSE, $export_flag = FALSE) 210 $e = error_reporting(0); 211 if (is_array($array) || is_object($array)) { 212 $pa = new printAClass; 213 if ($show_object_vars) { 214 $pa->show_object_vars = TRUE; 217 $pa->export_flag = $export_flag; 220 $pa->print_a($array); 222 $output = &$pa->output; 224 $output = '<span style="color:red;font-size:small;
">print_a( '.gettype($array).' )</span>'; __construct()
printAClass constructor
print_a class and helper function prints out an array in a more readable way than print_r() ...
print_a($array, $iteration=FALSE, $key_bg_color=FALSE)