Sometimes we need to check that whether a array key exists in our array or not. So we can check it in our laravel app using Arr facades or helper function in Laravel.
Hello Artisan, in this quick example i will show you how we can use Arr::exists() in our Laravel application. The Arr::exists
method in Laravel checks that the given key exists in the provided array:
See the given example of Arr::exists()
use Illuminate\Support\Arr;
$array = ['name' => 'John Doe', 'age' => 17];
$exists = Arr::exists($array, 'name');
// true
$exists = Arr::exists($array, 'salary');
// false
So now you can use it to check array key in you Laravel application. Hope it can help you.
#laravel #laravel-helper