how to get value from array in laravel



PHP Snippet 1:

echo $memus[0]['name'];

PHP Snippet 2:

foreach ($memus as $memu) {
       echo $memu['name'];
}

PHP Snippet 3:

collect($arrayName);

$filtered = $arrayName->where('parent', 0);

$filtered->all();

PHP Snippet 4:

{{memus[0]->id}}

PHP Snippet 5:

echo ($menus[0]['parent'] == 0) ? $menus[0]['name'] : '';

PHP Snippet 6:

 foreach ($menus as $menu) {
        if($menu['parent'] == 0){
            echo $menu['name'];
        }
    }

PHP Snippet 7:

  $memus  = Menu::where('parent', 0)->get()->toArray();
    $arr = array();
    foreach ($memus as $s) {
        array_push($arr,$s->buy_product_id)
    }