Or is there a better way to quickly output the contents of an array (multidimensional or what not). Thanks.
The print_r() function is a built-in function in PHP and is used to print or display information stored in a variable.
The api. php file is in C:\Program Files\xampp\htdocs\project\app\api\api.
The python print statement does a good job of formatting multidimesion arrays without requiring the print_r available in php.
As the definition for print states that each object is converted to a string, and as simple arrays print a '[' followed by a comma separated list of object values followed by a ']', this will work for any depth and shape of arrays.
For example
>>> x = [[1,2,3],[4,5,6]] >>> print x [[1, 2, 3], [4, 5, 6]]
If you need more advanced formatting than this, AJs answer suggesting pprint is probably the way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With