In this tutorial, We will learn how to work the laravel array has() function. The Arr::has method checks whether a given item exists in an array or not.


Example:


Create any controller file and and put the following code


<?php

namespace App\Http\Controllers;
use Illuminate\Support\Arr;

class HomeController extends Controller {

 
    public function index() {
        $array = ['car' => ['name' => 'Desk', 'price' => 100]];
        $contains = Arr::has($array, 'car.name');
        // true
        $contains = Arr::has($array, ['car.price', 'car.discount']);

        // false
    }

}



Output:

True
false


Thanks, May this example will help you.