Tribe__Utils__Array::get_in_any( array $variables, array|string $indexes, mixed $default = null )
Find a value inside a list of array or objects, including one nested a few levels deep.
Contents
Parameters
- $variables
-
(array) (Required) Array of arrays or objects to search within.
- $indexes
-
(array|string) (Required) Specify each nested index in order. Example: array( 'lvl1', 'lvl2' );
- $default
-
(mixed) (Optional) Default value if the search finds nothing.
Default value: null
Return
(mixed) The value of the specified index or the default if not found.
Source
File: src/Tribe/Utils/Array.php
public static function get_in_any( array $variables, $indexes, $default = null ) {
foreach ( $variables as $variable ) {
$found = self::get( $variable, $indexes, '__not_found__' );
if ( '__not_found__' !== $found ) {
return $found;
}
}
return $default;
}
Changelog
| Version | Description |
|---|---|
| 4.7.7 | Introduced. |