Home > Backend Development > PHP Tutorial > PHP print array method in separate lines

PHP print array method in separate lines

little bottle
Release: 2023-04-05 20:58:02
forward
3676 people have browsed it

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" } */
Copy after login

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!

Related labels:
php
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template