Print an Array in PHP

Printing an array can be quite useful when debugging your PHP code and luckily PHP makes the task simple.

The print_r(array) function takes any array as an argument and iterates through it, printing the results to standard out as it goes.

For example:

<?php
$myArray = array("One", "Two", "Three");
print_r($myArray);
?>

The above code will display the contents of $myArray.

Trackback URL for this post:

http://www.farbyte.com/blog/trackback/5
tagged in

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.