PHP print array - Print complete php arrays
This is a small tutorial how to print array in PHP. You will learn all the way you can display, print the content of an array.
|Name:||PHP print array|
Bookmark PHP print array
Step 2 - Print complete php arrays
PHP print array
The other most frequently used php print array method is when you want to display all values from an array. Using our colorList example array you can create a loop to display all values. Here you have more possibilities but PHP has a special loop for this purpose. It is called foreach. With foreach you can visit all elements in a loop and display its value, key or both if you want. The most simplest code example looks like this:
Print array for debugging purpose
Finally I will show you how to print the complete array content with a single function call. PHP has 2 built in functions to display a complete array. They are the print_r and the var_dump. Both are doing the same but var_dump gives you a little bit more information. It displays not only key and values but variable types as well.
However the usage are similar:
Previous Step of PHP print array
Tags: php print array, print array, php array, php, print, array