Description
Return the array[index] or array->index (for an object) or a default value if not setNote: This code is slightly more efficient with the default being assigned in the else than when there is just one assignment of $value = $default right at the start where slightly more is 2 or 3 microseconds – measured on a laptop.
Usage
bw_array_get( $array, $index, $default );Parameters
- $array
- ( mixed ) required –
- $index
- ( mixed ) required –
- $default
- ( mixed ) optional –
Returns
voidSource
File name: oik-bwtrace/includes/bwtrace.phpLines:
1 to 22 of 22
function bw_array_get( $array, $index, $default=NULL ) { if ( isset( $array ) ) { if ( is_array( $array ) ) { if ( isset( $array[$index] ) || array_key_exists( $index, $array ) ) { $value = $array[$index]; } else { $value = $default; } } elseif ( is_object( $array ) ) { if ( property_exists( $array, $index ) ) { $value = $array->$index; } else { $value = $default; } } else { $value = $default; } } else { $value = $default; } return( $value ); }View on GitHub View on Trac
Called by
1 to 15 of 488
- api_call_mapper::map() –
- bobbcomp::bw_array_get_dcb() – Return the array[index] or build the result by calling $callback, passing the $default as the arg.
- bw() – Return the styled "Bobbing Wide" string
- bwsc_jquery() – Implement the [bw_jq] shortcode
- BW_::bw_emailfield() – Form an "email" field
- BW_::bw_emailfield_arr() – Create an emailfield for an array options field
- BW_::bw_radio() – Display a group of radio buttons
- BW_::bw_select_arr() – Create a select for an array options field
- BW_::bw_textarea() – Form a "textarea" field
- BW_::bw_textarea_arr() – Create a textarea for an array options field
- BW_::bw_textarea_cb_arr() – Create an optional textarea
- BW_::bw_textfield() – Form a text field
- BW_::bw_textfield_arr() – Create a textfield for an array options field
- bw_accordion() – Display pages styled for jQuery accordion
- bw_action_file() – Determine the name of the action file
