src/Util/ArrayUtils.php
public static function findElementsByKey($array, $key, &$targetArray = null, $prefix = "") {

        if ($array instanceof AssociativeArray) {
            $array = $array->toArray();
        }

        if (!$targetArray)
            $targetArray = array();

        foreach ($array as $itemKey => $value) {

            if ($itemKey === $key) {
                $targetArray[substr($prefix . "." . $key, 1)] = $value;
            } else if (is_array($value) || $value instanceof AssociativeArray) {

                if (is_numeric($itemKey)) {
                    $newPrefix = $prefix . "[" . $itemKey . "]";
                } else {
                    $newPrefix = $prefix . "." . $itemKey;
                }

                ArrayUtils::findElementsByKey($value, $key, $targetArray, $newPrefix);
            }
        }

        return $targetArray;

    }
public static function findElementsByKey($array, $key, &$targetArray = null, $prefix = "") {

        if ($array instanceof AssociativeArray) {
            $array = $array->toArray();
        }

        if (!$targetArray)
            $targetArray = array();

        foreach ($array as $itemKey => $value) {

            if ($itemKey === $key) {
                $targetArray[substr($prefix . "." . $key, 1)] = $value;
            } else if (is_array($value) || $value instanceof AssociativeArray) {

                if (is_numeric($itemKey)) {
                    $newPrefix = $prefix . "[" . $itemKey . "]";
                } else {
                    $newPrefix = $prefix . "." . $itemKey;
                }

                ArrayUtils::findElementsByKey($value, $key, $targetArray, $newPrefix);
            }
        }

        return $targetArray;

    }
public static function findElementsByKey ( $ array , $ key , & $ targetArray = null , $ prefix = "" ) { if ( $ array instanceof AssociativeArray ) { $ array = $ array -> toArray ( ) ; } if ( ! $ targetArray ) $ targetArray = array ( ) ; foreach ( $ array as $ itemKey => $ value ) { if ( $ itemKey === $ key ) { $ targetArray [ substr ( $ prefix . "." . $ key , 1 ) ] = $ value ; } else if ( is_array ( $ value ) || $ value instanceof AssociativeArray ) { if ( is_numeric ( $ itemKey ) ) { $ newPrefix = $ prefix . "[" . $ itemKey . "]" ; } else { $ newPrefix = $ prefix . "." . $ itemKey ; } ArrayUtils :: findElementsByKey ( $ value , $ key , $ targetArray , $ newPrefix ) ; } } return $ targetArray ; }
Find elements by key.

@param $array
@param $key
Find elements by key .