SproutCMS

This is the code documentation for the SproutCMS project

function iterableFirst()

Gets the first key value pair of an iterable

This is to replace `reset` which has been deprecated in 7.2. While this lacks the
stateful behaviour of the original (i.e. changing the internal pointer) it does
recreate the most used feature: fetching the first element without knowing its key.

Usage

array|null Sprout::iterableFirst ( iterable $iter );

Example

list ($key, $value) = Sprout::iterableFirst(['an' => 'array']);

Arguments

  1. iterable $iter
    An array or Traversable

Return value

  • array
    An array of [key, value] or null if the iterable is empty
  • null
    An array of [key, value] or null if the iterable is empty