// Created on savesnippets.com ยท https://savesnippets.com/w6xS8M4GLaGZyS ['profile' => ['email' => 'a@x.com']]]; echo getPath($data, 'user.profile.email'); // a@x.com echo getPath($data, 'user.profile.phone', 'unknown'); // unknown echo getPath($data, 'foo.bar.baz', 'fallback'); // fallback