function for setting-search

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-06 10:59:55 +01:00
parent a3a33c0da4
commit 3f9769103b
2 changed files with 174 additions and 130 deletions

View File

@@ -409,6 +409,19 @@ class PhpHelper
return $returnval;
}
public static function recursive_array_search($needle, $haystack, &$keys = array(), $currentKey = '')
{
foreach ($haystack as $key => $value) {
$pathkey = empty($currentKey) ? $key : $currentKey . '.' . $key;
if (is_array($value)) {
self::recursive_array_search($needle, $value, $keys, $pathkey);
} else if (stripos($value, $needle) !== false) {
$keys[] = $pathkey;
}
}
return true;
}
/**
* function to check a super-global passed by reference
* so it gets automatically updated