$item) { if (is_array($item) && isset($item[0]) && is_string($item[0]) && 2 === count($item)) { if ('object' === $item[0]) { $parts = explode('\\', $item[1]); $short = array_pop($parts); $formattedValue = sprintf('object(%s)', $item[1], $short); } elseif ('array' === $item[0]) { $formattedValue = sprintf('array(%s)', is_array($item[1]) ? $formatArgs($item[1]) : $item[1]); } elseif ('string' === $item[0]) { $formattedValue = sprintf("'%s'", htmlspecialchars($item[1])); } elseif ('null' === $item[0]) { $formattedValue = 'null'; } elseif ('boolean' === $item[0]) { $formattedValue = ''.strtolower(var_export($item[1], true)).''; } elseif ('resource' === $item[0]) { $formattedValue = 'resource'; } else { $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1]), true)); } } elseif (is_object($item)) { $formattedValue = get_class($item); } elseif (is_string($item)) { $formattedValue = ''.htmlspecialchars($item).''; } elseif (is_array($item)) { $formattedValue = sprintf('array(%s)', $formatArgs($item)); } else { $formattedValue = ''; } $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); } return implode(', ', $result); }; echo "