I need a clarification regarding the difference between data objects and arrays in PHP+mySQL and something I think is related: representing "array-type data" with { }
vs [ ]
I am using PHP, mySQL and RedBean ORM.
I pulled out a record (table row) from a table, and stored it in PHP in a variable named $record
When I run the following command:
echo $record;
I get the following output:
{"id":"1","name":"Frankie Johnnie & Luigo Too","address":"939 W El Camino Real, Mountain View, CA","lat":"37.386429","lng":"-122.085838","fee":"0.00"}
Next, I pulled out column names from a table and stored them in a variable named $fields
When I run the following command:
echo $fields;
I get the following output:
Notice: Array to string conversion in /Applications/XAMPP/xamppfiles/htdocs/devserver/crud/show.php on line 18
Array
When I run the following command:
print_r($fields);
I get the following output:
Array ( [id] => int(11) [name] => varchar(60) [address] => varchar(80) [lat] => float(10,6) [lng] => float(10,6) [fee] => decimal(5,2) )
Why does echo
work for the first, but print_r
is needed for the second? What do I need to learn to brush up on what's happening here?