Array Helper

Provides additional functions for working with arrays.

Summary
Array HelperProvides additional functions for working with arrays.
Functions
array_index_by_key()When given an array of arrays (or objects) it will return the index of the sub-array where $key == $value.

Functions

array_index_by_key()

if (!function_exists('array_index_by_key'))

When given an array of arrays (or objects) it will return the index of the sub-array where $key == $value.

Given the following array

$array = array(
  [0] => array(
      'value' => 1
  ),
  [1] => array(
      'value' => 2
  )
);

you could find the index of the second array with the command

// Returns 1
array_index_by_key('value', 2, $array);

Parameters

$keyThe key to search on
$valueThe value the key should be
$arrayThe array to search through
$identicalWhether to perform a strict type-checked comparison

Returns

An INT that is the index of the sub-array, or false.

if (!function_exists('array_index_by_key'))
When given an array of arrays (or objects) it will return the index of the sub-array where $key == $value.
Close