How to avoid typing <pre class = "prettyprint-override"> when viewing arrays ... any ideas?
8 answers
It's funny that you should ask about it, I just wrote a short function to save me from the pain associated with this.
function pre($option = "open"){
if (is_object($option) || is_array($option)):
print "<pre>";
print_r($option);
print "</pre>";
else:
$option=="open"?print "<pre>": print "</pre>";
endif;
}
, . , . , (, 1)
:.
pre($result); //prints in pre tags
pre(); //just prints <pre>
print "hello";
pre(1); //just prints </pre>
-1