# code-snippets/3.10.0/vendor/typisttech/imposter/src/ArrayUtil.php

Code Snippets, version 3.10.0. 36 lines.

- Page: https://pluginprobe.com/plugins/code-snippets/3.10.0/code/vendor/typisttech/imposter/src/ArrayUtil.php
- Raw: https://pluginprobe.com/plugins/code-snippets/3.10.0/raw/vendor/typisttech/imposter/src/ArrayUtil.php
- Modified: 2025-10-16T19:08:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-snippets/3.10.0/code/vendor/typisttech/imposter/src/ArrayUtil.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace TypistTech\Imposter;

class ArrayUtil
{
    public static function flattenMap(callable $callable, array $array): array
    {
        $map = array_map($callable, $array);

        return static::flatten($map);
    }

    /**
     * Flatten array by one level.
     *
     * @param array $array
     *
     * @return array
     */
    public static function flatten(array $array): array
    {
        $result = [];
        foreach ($array as $item) {
            if (is_array($item)) {
                $result = array_merge($result, array_values($item));
            } else {
                $result[] = $item;
            }
        }
        return $result;
    }
}

```
