You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, this one could be a solution for the given problem. Do you think that every * should be only for one position? What I mean is that it won't work for:
I think it should also work for both our examples. If we add something like this, we should be sure to document it well. Any thoughts on how to approach this code-wise?
/** * Recursive find in the given $array and $needle. * @param $array The input array. * @param $needle The needle to find. * @return Returns all the values find by the given key. */functionrecursiveFind(array$array, $needle)
{
$iterator = newRecursiveArrayIterator($array);
$recursive = newRecursiveIteratorIterator($iterator,
RecursiveIteratorIterator::SELF_FIRST);
$results = array();
foreach ($recursiveas$key => $value) {
if ($key === $needle) {
array_push($results, $value);
}
}
return$results;
}
The example is contrived, but I've needed something similar in a project already. Not quite sure how we're gonna figure it out though 😕
The text was updated successfully, but these errors were encountered: