Exemplo n.º 1
0
    public function print_r($array_in, $title = '')
    {
        if (is_object($array_in)) {
            $json = json_encode($array_in);
            $array_in = json_decode($json, true);
        }
        if (is_array($array_in)) {
            if (count($array_in) == 0) {
                //				$result .= '<tr><td><font face="Verdana,Arial" size="1"><strong>EMPTY!</strong></font></td></tr>';
            } else {
                $result = '
				<table class="table table-striped table-bordered">';
                if ($title) {
                    $result .= '
					<tr>
					<th colspan="2">
					' . htmlspecialchars($title) . '
					</th>
					</tr>
					';
                }
                if (is_array($array_in) && count($array_in)) {
                    foreach ($array_in as $key => $val) {
                        if ((string) $key or $val) {
                            if (!$tr_type or $tr_type == 'even') {
                                $tr_type = 'odd';
                            } else {
                                $tr_type = 'even';
                            }
                            $result .= '<tr class="' . $tr_type . '">
							<td valign="top" class="print_r_key">' . htmlspecialchars((string) $key) . '</td>
							<td class="print_r_value">';
                            if (is_array($val)) {
                                //							$result .= t3lib_utility_Debug::viewArray($val);
                                $result .= mslib_befe::print_r($val);
                            } elseif (is_object($val)) {
                                $string = '';
                                if (method_exists($val, '__toString')) {
                                    $string .= get_class($val) . ': ' . (string) $val;
                                } else {
                                    $string .= print_r($val, true);
                                }
                                $result .= '' . nl2br(htmlspecialchars($string)) . '<br />';
                            } else {
                                if (gettype($val) == 'object') {
                                    $string = 'Unknown object';
                                } else {
                                    $string = (string) $val;
                                }
                                $result .= nl2br(htmlspecialchars($string)) . '<br />';
                            }
                            $result .= '</td>
						</tr>';
                        }
                    }
                }
                $result .= '</table>';
            }
        } else {
            $result = '<table class="table table-striped table-bordered">
				<tr>
					<td>' . nl2br(htmlspecialchars((string) $array_in)) . '</td>
				</tr>
			</table>';
            // Output it as a string.
        }
        return $result;
    }