note 85148 added to function.print-r
| From: | adminatswivelgamesdotcom at osu1 dot php dot net | Date: | Sun, 17 Aug 2008 20:44:23 +0000 |
| Subject: | note 85148 added to function.print-r | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143572@lists.php.net to get a copy of this message | ||
I was having problems using print_r because I didn't like the fact that if tags where included
in the array it would still be parsed by the browsers.
Heres a simple fix for anyone who is having the same problem as I did. This will output your text
properly for viewing through the browser instead of the browser's "view source" or
CLI.
Script:
<?php
$MyArray[0]="<div align='center'>My Text</div>";
echo "<pre>".htmlspecialchars(print_r($MyArray,true))."</pre>";
?>
Output:
<pre>Array
(
[0] => <div align='center'>My Text</div>
)
</pre>
----
Server IP: 209.41.74.194
Probable Submitter: 64.217.182.235
----
Manual Page -- http://www.php.net/manual/en/function.print-r.php
Edit -- https://master.php.net/note/edit/85148
Del: integrated -- https://master.php.net/note/delete/85148/integrated
Del: useless -- https://master.php.net/note/delete/85148/useless
Del: bad code -- https://master.php.net/note/delete/85148/bad+code
Del: spam -- https://master.php.net/note/delete/85148/spam
Del: non-english -- https://master.php.net/note/delete/85148/non-english
Del: in docs -- https://master.php.net/note/delete/85148/in+docs
Del: other reasons-- https://master.php.net/note/delete/85148
Reject -- https://master.php.net/note/reject/85148
Search -- https://master.php.net/manage/user-notes.php