//object init
$object = (object) [
'propertyOne' => 'foo',
'propertyTwo' => 42,
];
$o= new stdClass();
$o->a = 'new object';
OR
$o = (object) ['a' => 'new object'];
In a variable:
$variable = (object) "lol";
<?php
class Bike
{
function model()
{
$model_name = 'cd100';
echo "bike model:$model_name";
}
}
$obj = new Bike();
$obj->model();
?>
<?php
$fruitsArray = array(
"apple" => 20,
"banana" => 30
);
echo $fruitsArray['banana'];