<?php
/// or since it is in general func
use Kit\General\GeneralFunc;
// then
GeneralFunc::recursiveFind($needle, 'key');
//////
// don't forget, i wrote my own version of it to get them ALL
GeneralFunc::recursiveFindAll($needle, 'key');
//////
public function recursiveFind(array $haystack, $needle)
{
$iterator = new \RecursiveArrayIterator($haystack);
$recursive = new \RecursiveIteratorIterator(
$iterator,
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($recursive as $key => $value) {
if ($key === $needle) {
return $value;
}
}
}
// example usage:
$output['rel']= $this->recursiveFind($array,'synonym');