The Print_r () and Var_dump () functions can print out the entire array contents and structure.
Print_r ()
Using the Print_r () function, you can print out the entire array contents and structure, displaying the keys and elements in a certain format. Note the Print_r () function is not only for printing, it is actually used to print easily understandable information about variables.
Grammar:
BOOL Print_r (mixed expression) Example:
<?php
$arr _age = Array (a);
Print_r ($arr _age);
? >
Run the example output:
Array ([0] => [1] => [2] => 25) To view the output of the page source code, you can see more readable format:
Array
(
[0] => [
1] =>
[2] =>
)
var_dump ()
Like the Print_r () function, the Var_dump () function can also be used to print the data and structure of an array. However, the Var_dump () function is more powerful than print_r (), and can print multiple variables at the same time and give the variable type information.
Example:
<?php
$arr _age = Array (a);
Var_dump ($arr _age);
? >
Run the example output:
Array (3) {
[0]=>
int (a)
[1]=>
int ()
[2]=>
int
}
The Print_r () and Var_dump () functions are typically used by the debugger, and more often by using echo to output specific array cell values.
The above PHP print_r and var_dump output array is a small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.