mardi 3 juillet 2018

Laravel 5: How to use array_get method to access an attribute with a dot inside

I have an array like this:

$data = [
  "x" => [
    "y" => 5,
    "a.b" => 10
  ]
]

I can access x.y like this:

array_get($data, 'x.y');

However, how can I access x.(a.b) (sometimes written as x.a->b)

I tried the following:

array_get($data, 'x.a.b');
array_get($data, 'x.a->b');

But neither seems to work.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire