November 10th, 2007 at

Displaying array contents in an easy to use format using php

in: Scripts

This function displays the contents of any array in a nicely formatted display.

It combines the <pre> </pre> and the print_r function into one making it easy to use and the displayed results easier to understand.

The function uses one input:

$array - the array variable to be displayed

This is a great function for testing and debugging during developing stages of a script.

######## start script

function printr($array) {

  echo "<pre>";
  print_r($array);
  echo "</pre>";

}

// example
$array = array(1, 2, array(0 => "zero", 1 => "one"));

// normal print_r function
print_r($array);

// printr function
printr($array);

######## finish script

 Click here to download the complete php script

 

RSS feed for comments on this post | TrackBack URI