Home > Article > Backend Development > PHP print array method in separate lines
We all know that php has two ways to print arrays.
$arr = array( "a"=>"orange", "b"=>"banana", "c"=>"apple"); echo "<pre class="brush:php;toolbar:false">"; print_r($arr); var_dump($arr); echo ""; /**显示效果 Array ( [a] => orange [b] => banana [c] => apple ) array(3) { ["a"]=> string(6) "orange" ["b"]=> string(6) "banana" ["c"]=> string(5) "apple" } */
Like the print_r() function, the var_dump() function can also be used to print the data and structure of the array. However, the var_dump() function is more powerful than print_r(). It can print multiple variables at the same time and give the type information of the variables.
[Recommended course: PHP video tutorial]
The above is the detailed content of PHP print array method in separate lines. For more information, please follow other related articles on the PHP Chinese website!