# data_get(): Warning with array keys with dots - Laravel Tips

# Ingredients 

## `data_get()`

`data_get()` is a useful helper function in Laravel that retrieves values from a nested array or an object using _dot notation_.
The strength of `data_get()` is also that it accepts wildcards.

> If you don't know or you don't use it, I suggest you to discover it ([here the docs](https://laravel.com/docs/10.x/helpers#method-data-get)), with _brothers_ and _sisters_: [`data_set()`](https://laravel.com/docs/10.x/helpers#method-data-set), [`data_fill()`](https://laravel.com/docs/10.x/helpers#method-data-fill), [`data_forget()`](https://laravel.com/docs/10.x/helpers#method-data-forget)! ;)

## `Arr::get()`

Unlike `data_get()`, [`Arr::get()`](https://laravel.com/docs/10.x/helpers#method-array-get) works only on arrays and it doesn't accept wildcards.

---

# The Tip

Let’s show this example:

```php
$array = [
    'key.sub' => 'a-value'
];

data_get($array, 'key.sub');  // --> null ❗

// instead...
\Arr::get($array, 'key.sub'); // --> "a-value"
```

Instead of this:

```php
$array = [
    'key' => [
        'sub' => 'a-value'
    ]
];

data_get($array, 'key.sub');  // --> "a-value"

// and also...
\Arr::get($array, 'key.sub'); // --> "a-value"
```

---

# And you?

- Did you use already `data_get()`?
- And `Arr::get()`?
- Did you know that difference?

**Leave your comment!**

---

✸ Enjoy your coding!

#### If you liked this post, don't forget to **Subscribe** to my newsletter!

