Skip to content

Instantly share code, notes, and snippets.

@oranj
Created September 15, 2011 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oranj/1219648 to your computer and use it in GitHub Desktop.
Save oranj/1219648 to your computer and use it in GitHub Desktop.
dump
if (! function_exists('dump')) {
// Human readable print_r rendered by the browser.
function dump($var, $return = false) {
$str = '<pre style="text-align:left; border:1px solid #ccc; color:#000; background:#fff; margin:10px; padding:10px; background:rgba(255,255,255,0.7);">'.htmlentities(print_r($var, true)).'</pre>';
while (preg_match('/((?!\[\[)([0-9]{10})(?!\]\]))/', $str, $matches)) {
$str = preg_replace('/'.$matches[1].'/', '{<strong>'.date('r', $matches[1])."</strong> <em>[[".$matches[1]."]]</em>}", $str);
}
if ($return) { return $str; } echo $str;
}
}
@oranj
Copy link
Author

oranj commented Nov 18, 2011

Added styling to help when things are center aligned;

@oranj
Copy link
Author

oranj commented Jan 30, 2012

now replaces 10 digit numbers with 'r' formatted dates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment