Tribe__Customizer::search_var( array $variable = null, array $indexes = array(), mixed $default = null )
A method to easily search on an array
Contents
Parameters
- $variable
-
(array) (Optional) Variable to be searched
Default value: null
- $indexes
-
(array) (Optional) The index that the method will try to retrieve
Default value: array()
- $default
-
(mixed) (Optional) If the variable doesn't exist, what is the default
Default value: null
Return
(mixed) Return the variable based on the index
Source
File: src/Tribe/Customizer.php
public static function search_var( $variable = null, $indexes = array(), $default = null ) {
if ( is_object( $variable ) ) {
$variable = (array) $variable;
}
if ( ! is_array( $variable ) ) {
return $variable;
}
foreach ( (array) $indexes as $index ) {
if ( ! is_array( $variable ) || ! isset( $variable[ $index ] ) ) {
$variable = $default;
break;
}
$variable = $variable[ $index ];
}
return $variable;
}
Changelog
| Version | Description |
|---|---|
| 4.0 | Introduced. |