Php outputs code examples of arrays in beautiful formats
| This article introduces how to output a code example of an array in beautiful format in php. For more information, see.
Php output array format, preset beautiful format, which is worth reference: Sample code: "; Print_r ($ object); echo" ";}else {echo htmlspecialchars ($ object) ;}}?>
Appendix: three common methods for php output arrays. Sample code:
// Array used for testing $ bbbb = array ("11" => "aaa", "22" => "bbb ");
// Method 1: output value only. value cannot output keyforeach ($ bbbb as $ color) echo $ color;
// Method 2: both value and key can output foreach ($ bbbb as $ key => $ value) echo $ key. "=>". $ value;
// Method 3: both value and key can output while ($ color = each ($ bbbb) {echo $ color ['key'] ;}?>
I 'd like to introduce this to you. I hope the above several pieces of code about php array output will be helpful to you. |