You appear to be a bot. Output may be restricted
Description
Return the array[index] or build the result by calling $callback, passing the $default as the arg.Notes: dcb = deferred callback Use this function when applying the default might take some time but would be unnecessary if the $array[$index] is already set. You can also use this function when the default value is a string that you want to be translated.
- /10/23 – When the parameter was passed as a null value e.g. "" then it was being treated as NULL hence the default processing took effect. In this new verision we replace the NULLs in the code body with $default So bw_array_get() can return a given NULL value which will then override the default. In this case, if the parameter that is passed turns out to be the default value then this will also be translated. Note: It could could still match a default null value Also: We don't expect a null value for the default callback function __()
- /12/04 – we have to allow for the value being set as 0 which differs from a default value of NULL so the comparison needs to be identical ( === ) rather than equal ( == )
- /02/27 – In cases where value found may be the same as the default and the dcb function could mess this up then it's advisable to NOT use this function.
- $array
- ( array ) required – array from which to obtain the value
- $index
- ( string ) required – index of value to obtain]
- $default
- ( mixed ) optional – parameter to the $callback function
- $callback
- ( string ) optional default: __ – function name to invoke – defaults to invoking __()
- $text_domain
- ( mixed ) optional default: oik –
Usage
bobbcomp::bw_array_get_dcb( $array, $index, $default, $callback, $text_domain );
Parameters
Returns
voidSource
File name: oik/libs/class-bobbcomp.phpLines:
1 to 11 of 11
static function bw_array_get_dcb( $array, $index, $default = NULL, $callback='__', $text_domain="oik" ) { $value = bw_array_get( $array, $index, $default ); if ( $value === $default ) { if ( is_callable( $callback ) ) { $value = call_user_func( $callback, $default, $text_domain ); } else { bw_backtrace(); } } return( $value ); }View on GitHub View on Trac