Overview

Namespaces

  • None
  • VSP
    • Core
      • Abstracts
      • Interfaces
      • Traits
        • WC_Compatibility
    • Deprecation
    • Helper
    • Modules
      • Addons
      • Logger

Traits

  • Array_Helper
  • Framework
  • String_Helper
  • URL
  • WC_Helper
  • WP
  • Overview
  • Namespace
  • Class

Trait Array_Helper

Trait VSP_Framework_Array_Trait

Direct Known Users

VSP\Helper
Namespace: VSP\Core\Traits
Author: Varun Sridharan varunsridharan23@gmail.com
Located at includes/core/traits/class-array-helper.php
Methods summary
public static array|boolean
# json_to( string $data = '', boolean $to_object = false )

Converts JSON String To Array

Converts JSON String To Array

Parameters

$data
$to_object
if Set To true then it returns as object or array

Returns

array|boolean
public static array
# array_group_by( $items, $group_callback_function )

Groups the elements of an array based on the given function.

Groups the elements of an array based on the given function.

Parameters

$items
$group_callback_function

Returns

array

Example

array_group_by(['one', 'two', 'three'], 'strlen') // [3 => ['one', 'two'], 5 => ['three']]
public static boolean
# array_has_duplicates( $items )

Checks a flat list for duplicate values. Returns true if duplicate values exists and false if values are all unique.

Checks a flat list for duplicate values. Returns true if duplicate values exists and false if values are all unique.

Parameters

$items

Returns

boolean
public static array|object
# parse_args( array|object $args, array|object $defaults, boolean $deep = false, boolean $preserve_type = true, boolean $preserve_integer_keys = false )

Like wp_parse_args but supports recursivity By default converts the returned type based on the $args and $defaults

Like wp_parse_args but supports recursivity By default converts the returned type based on the $args and $defaults

Parameters

$args
Values to merge with $defaults.
$defaults
Array, Object that serves as the defaults or string.
$deep
if set to true then it will do a deep merge.
$preserve_type
Optional. Convert output array into object if $args or $defaults if it is. Default true.
$preserve_integer_keys
Optional. If given, integer keys will be preserved and merged instead of appended.

Returns

array|object
$output Merged user defined values with defaults.
public static array
# filter_array_data( array $required, array $existing )

Filters An Array based on the given value

Filters An Array based on the given value

Parameters

$required
$existing

Returns

array

Example

$required = array('somekey1','somekey2'); $existing = array('somekey1'=>'OMG','somekey2'=>"EOO",'somekey3'=>'okclose'); $return = array('somekey1' => 'OMG','somekey2' => "EOO");


API documentation generated by ApiGen