Voting

: max(seven, seven)?
(Example: nine)

The Note You're Voting On

Soaku
7 years ago
[email protected] posted a function that will echo print_r output with proper new lines in HTML files. He used <pre> for it to work, but that might not be always the best method to go. For example, it is not valid to place <pre> inside <p>.

Here is my way to do this:

<?php

function print_rbr ($var, $return = false) {
$r = nl2br(htmlspecialchars(print_r($var, true)));
if (
$return) return $r;
else echo
$r;
}

?>

This function will:

- Place <br> where newlines are,
- Escape unsecure characters with HTML entities.

<< Back to user notes page

To Top