laravel in array code example

Example 1: laravel where in array

$items = DB::table('items')->whereIn('id',[1,2,..])->get();

Example 2: laravel where in array

$items = Item::whereIn('id', [1,2,..])->get();

Example 3: laravel arrays

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

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

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

Example 4: laravel take value from different array by key

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

$array = array_fetch($array, 'developer.name');

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

Example 5: laravel where in array

$items = Item::whereIn('id', [1,2,..])->get();

Example 6: where is in array laravel

$items = DB::table('items')->whereIn('id', [1, 2, 3])->get();

Tags:

Php Example