I have search for creating multiple objects with same properties but didn't find a solution. So I am creating this object.
$monthData = new \stdClass();
foreach($quotesData as $datas){
$monthData->name = $datas[0] ["monthname"];
$monthData->data = $datas[0] ["price"];
}
but it is only creating one object
and when i am doing $monthData[$i]->name then php throws an exception Cannot use object of type stdClass as array in file
so I want the resultant object like this
{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}
but it gave me only one object in return at this time
{
name: 'Jane',
data: [1, 0, 4]
}