I’m trying to define an array and add elements to it, but there’s a problem with that
$prodectsum = array();
$prodectsum->push((object)['name' => 'mmm', 'color' => 'red']);
Define an array in Laravel
I’m trying to define an array and add elements to it, but there’s a problem with that
$prodectsum = array();
$prodectsum->push((object)['name' => 'mmm', 'color' => 'red']);
Define an array in Laravel
2
Answers
You can use Arr::add() or Arr::set() from Laravel Helpers.
See https://laravel.com/docs/9.x/helpers#method-array-add