Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 679 Bytes

get_in.md

File metadata and controls

35 lines (24 loc) · 679 Bytes

get_in

Description

Returns the value in a nested associative structure

Parameters

keys
Keys of the value to be returned.
elements
Elements to search in.
default
Default value to return in the case that the key not exists (`null` if not provided).

Examples

Extract the email from a nested structure:

<?php

use function Lambdish\Phunctional\get_in;

$user = [
    'username' => 'myfakeuser',
    'profile'  => ['name' => 'My Name', 'surname' => 'My Surname', 'email' => 'myfakeemail@gmail.com']
];

return get_in(['profile', 'email'], $user);

// => 'myfakeemail@gmail.com'