Concept
How can you print the contents of a PHP array in a readable format?
ComputerScienceOne / Useful Functions
"For convenience and debugging, a special function, print_r() allows you to print the contents of an array in a human-readable format that resembles the key-value initialization syntax above. For example,\n\n$arr = array(\n\n\"foo\" => 5,\n\n4 => \"bar\",\n\n0 => 3.14,\n\n\"baz\" => \"ten\"\n\n);\n\nprint_r($arr);\n\nwould end up printing\n\nArray\n\n(\n\n[foo] => 5\n\n[4] => bar\n\n[0] => 3.14\n\n[baz] => ten\n\n)"
Related Ideas
- How can you extract array keys and values and compare arrays in PHP?ComputerScienceOne · Iteration
- How does PHP support and create multidimensional arrays?ComputerScienceOne · Multidimensional Arrays
- How are elements added to the next available integer index in a PHP array?ComputerScienceOne · Removing Elements
- How can you iterate through an array using foreach?ComputerScienceOne · Adding Elements
- How can you iterate over indexed and associative arrays in PHP?ComputerScienceOne · Iteration
- How does key-value initialization define PHP array keys and values?ComputerScienceOne · Key-Value Initialization
- How do you create and index arrays in PHP?ComputerScienceOne · Creating Arrays
- How can strings be used as indices in PHP arrays?ComputerScienceOne · Strings as Indices