[Solved] get first element of an array


If you want the first element of an array, you should use reset. This function sets the pointer to the first element and returns it.

$firstValue = reset($value['record']['records']);

Edit.. after reading your question again, it seems, you dont want the first element.
You rather want this

if (isset($value['record']['records'][0]) && is_array($value['record']['records'][0])) {
    // multiple return values
} else {
    // single return value
}

Doing this is kind of error proun and i wouldn’t suggest that one function returns different kinds of array structures.

1

solved get first element of an array