Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arr::has()
// We import the support for this Helper
use Illuminate\Support\Arr;
$products = ['drinks' => ['Name' => 'Strawberry Juice', 'price' => '3.60']];
$check = Arr::has($products, 'drinks.name');
// We get true
$check = Arr::has($products, ['drinks.name', 'drinks.price']);
// We get true
$check = Arr::has($products, ['drinks.name', 'drinks.stock']);
// We get false, because the 'stock' field does not exist in the variable $products
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.