method_check_array( $item, $key )

Checks whether an array’s first element has a non‑empty value at a given key.


Description

Validates that $item is a non‑empty array with at least one element, and that the first element ($item[0]) has a non‑empty value at $key. Primarily used to validate CMB2 repeatable groups before iterating.


Parameters

$item (mixed) :
The variable to check. Must be an array with at least one element.

$key (string) :
The array key to check on the first element.


Return

(bool) true if validation passes, false otherwise.


Source

File: lib/helper-functions.php


Usage

PHP
if ( method_check_array( $social_links, 'service' ) ) {
    // Since we know that at least one items exists, we can add wrapper markup
    foreach ( $social_links as $link ) {
        // Safe to access $link['service']
    }
}