Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created April 7, 2020 00:00
Show Gist options
  • Save shameemreza/359c3670cd3c2ceab16011386563b073 to your computer and use it in GitHub Desktop.
Save shameemreza/359c3670cd3c2ceab16011386563b073 to your computer and use it in GitHub Desktop.
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