Arrays, Objects, and Collections in PHP
I got a data type from
DB::table('tableName')->
where('column1', 'no')->
get();
and I get an array of objects.
To make an object, we can do two things…
we can either do
$object = (object) [
'key1' => 'body1',
'key2' => 'body2'
];
or we can do
$object = new \stdClass();
$object->key1='body1';
$object->key2=22;
will work similarly.
There is also this thing called Collections, and it’s actually not a PHP thing but a Laravel thing.
We use it to make arrays and stuff.