[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

bw_array_get() – Return the array[index] or array->index (for an object) or a default value if not set

You appear to be a bot. Output may be restricted

Description

Return the array[index] or array->index (for an object) or a default value if not set

Note: 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

void

Source

File name: oik-bwtrace/includes/bwtrace.php
Lines:
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

Published: March 11, 2017 | Last updated: December 21, 2017

Information

Function name: bw_array_get
Plugin ref: oik-bwtrace – debug trace for WordPress
Version: 3.4.1
Sourcefile: includes/bwtrace.php
File ref: includes/bwtrace.php
Deprecated?: No
API Letters: A,B,G

Recent plugin updates

cookie-cat v1.4.6 Upgrade to cookie-cat v1.4.6 for PHP 8.1 & PHP 8.2 support. ...
oik-fields v1.54.0 oik-fields v1.54.0 caters for the deprecation of get_page_by_title() in WordPress 6.2. ...
oik-clone v2.3.1 Upgrade to oik-clone v2.3.1 for cloning ACF checkbox and multiple select fields and/or comments attached to posts. ...
sb-chart-block v1.2.4 sb-chart-block v1.2.4 uses the latest chart.js and is tested with WordPress 6.3 ...
sb-children-block v1.2.2 sb-children-block v1.2.2 has been tested with WordPress 6.3 and Gutenberg 16.3.0 ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: herb@bobbingwide.com

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2023. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.3.1. PHP: 7.4.33. Memory limit: 768M