Array Helper

The array helper provides several functions to simplify more complex usages of arrays. It is not intended to duplicate any of the existing functionality that PHP provides - unless it is to vastly simplify their usage.

Loading this Helper

This helper is loaded using the following code:


Available Functions

The following functions are available:

  • $search (string) – The dot-notation string describing how to search the array
  • $values (array) – The array to search

The value found within the array, or null

Return type:


This method allows you to use dot-notation to search through an array for a specific-key, and allows the use of a the ‘*’ wildcard. Given the following array:

$data = [
    'foo' => [
        'buzz' => [
            'fizz' => 11
        'bar' => [
            'baz' => 23

We can locate the value of ‘fizz’ by using the search string “”. Likewise, the value of baz can be found with “”:

// Returns: 11
$fizz = dot_array_search('', $data);

// Returns: 23
$baz = dot_array_search('', $data);

You can use the asterisk as a wildcard to replace any of the segments. When found, it will search through all of the child nodes until it finds it. This is handy if you don’t know the values, or if your values have a numeric index:

// Returns: 23
$baz = dot_array_search('foo.*.baz', $data);