Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-14-2011, 09:26 PM   PM User | #1
redixx
New Coder

 
Join Date: Jun 2011
Posts: 56
Thanks: 0
Thanked 17 Times in 17 Posts
redixx is an unknown quantity at this point
print_r wrapper

This is just a simple little wrapper I always use in development for print_r(). I hate how it is just an enormous string of text, so I just wrap it in pre tags.

PHP Code:
function print_arr($array)
{
     echo 
'<pre>';
     echo 
print_r($array);
     echo 
'</pre>';

Simple, useful.
redixx is offline   Reply With Quote
Old 06-14-2011, 10:07 PM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
You can also write that this way so it's one line:
PHP Code:
echo '<pre>'print_r($arraytrue), '</pre>'
Inigoesdr is offline   Reply With Quote
Old 06-14-2011, 10:36 PM   PM User | #3
redixx
New Coder

 
Join Date: Jun 2011
Posts: 56
Thanks: 0
Thanked 17 Times in 17 Posts
redixx is an unknown quantity at this point
Nice, I didn't know about the second argument.
redixx is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:55 AM.


Advertisement
Log in to turn off these ads.