lp__array_column( $value, $column_key, $index_key )

Retrieves the values from a single column of a multidimensional array, using a specified key as the index.

Plugin

Namespace

Launchpad

Parameters

array

$value

The input array from which to extract values.

string

$column_key

The column of values to return.

string

$index_key

The column to use as the index/key.

Return

array

Return an array containing values from a single column of the input array, with keys from another column.

Source

File: \includes\lp-utility-functions.php

function lp__array_column( $value, $column_key, $index_key ) {

    $val = [];
    
    if( ! empty($value) && is_array( $value ) ) {
        $val = array_column( $value, $column_key, $index_key );
    }

    return $val;

}

Related

Used to insert a value or an array into an array before or after a specified identifier.

Used to checks if an array is associative.

Used to retrieve the value from an array based on a given key.

Used to checks if an array is associative.