how to get array in laravel code example

Example 1: laravel arrays

$array = array(array('name' => 'Taylor'), array('name' => 'Dayle'));

$array = array_pluck($array, 'name');

// array('Taylor', 'Dayle');

Example 2: how to print array in laravel blade

<?php dd($array); ?>

Example 3: laravel return a single dimensional array

$catcount    = 2;
    $parents_ids = [];
    for ($i = 0; $i < $catcount; $i++) {
        $parents_ids[] = $userCategory[$i];
    }
    $subCats = Category::whereIn('parent_id', $parents_ids)->pluck('id');

Example 4: how to print array in laravel blade

@foreach ($watchFolder as $w)
    {{ $w->name }}    
@endforeach

Tags:

Php Example