PHP Print_r function: How to use it with array

The print_r function

The print_r PHP function is used to display data stored in an array on the screen i.e. Structured Visual representation of array data in the Human Readable format which is shown below.

Syntax of print_r

Following is the syntax to use the print_r function:



In PHP, the print_r function is used to output data stored in an array which is humanly readable. See the example below:

Example of print_r function





Usage of Print_r

Sometimes it is handy to see the visual structure of your arrays, particularly dynamically generated, due to its complexity. The PHP print_r really helps in this case.





Array

(

[a] => We are

[b] => testing
[c][/c]

=> print_r function

)

Was this article helpful?

Related Articles

Leave A Comment?