method pick documentation in bbn\X
Returns a reference to a subarray targeted by an array $keys.
Example
$ar = [
'session' => [
'user' => [
'profile' => [
'admin' => [
'email' => 'test@test.com'
]
]
]
]
];
X::hdump(X::pick($ar,['session', 'user', 'profile', 'admin', 'email']));
// string test@test.com
X::hdump(X::pick($ar,['session', 'user', 'profile', 'admin']));
// ["email" => "test@test.com",]
function(array $ar, array $keys)
{
while (\count($keys)) {
$r = array_shift($keys);
if (is_array($ar) && array_key_exists($r, $ar)) {
$ar = $ar[$r];
if (!count($keys)) {
return $ar;
}
}
}
}
Returns a reference to a subarray targeted by an array $keys. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions