public static function flatten($data, $seperator = '_', $prefix = null, array &$result = null)
    {
        if ($result === null) {
            $result = array();
        }

        if ($data instanceof \stdClass) {
            $data = (array) $data;
        } elseif (!is_array($data)) {
            throw new InvalidArgumentException('Data must be either an stdClass or array');
        }

        foreach ($data as $key => $value) {
            if ($value instanceof \stdClass || is_array($value)) {
                self::flatten($value, $seperator, $prefix . $key . $seperator, $result);
            } else {
                $result[$prefix . $key] = $value;
            }
        }

        return $result;
    }
public static function flatten($data, $seperator = '_', $prefix = null, array &$result = null)
    {
        if ($result === null) {
            $result = array();
        }

        if ($data instanceof \stdClass) {
            $data = (array) $data;
        } elseif (!is_array($data)) {
            throw new InvalidArgumentException('Data must be either an stdClass or array');
        }

        foreach ($data as $key => $value) {
            if ($value instanceof \stdClass || is_array($value)) {
                self::flatten($value, $seperator, $prefix . $key . $seperator, $result);
            } else {
                $result[$prefix . $key] = $value;
            }
        }

        return $result;
    }
public static function flatten ( $ data , $ seperator = '_' , $ prefix = null , array & $ result = null ) { if ( $ result === null ) { $ result = array ( ) ; } if ( $ data instanceof \ stdClass ) { $ data = ( array ) $ data ; } elseif ( ! is_array ( $ data ) ) { throw new InvalidArgumentException ( 'Data must be either an stdClass or array' ) ; } foreach ( $ data as $ key => $ value ) { if ( $ value instanceof \ stdClass || is_array ( $ value ) ) { self :: flatten ( $ value , $ seperator , $ prefix . $ key . $ seperator , $ result ) ; } else { $ result [ $ prefix . $ key ] = $ value ; } } return $ result ; }
Converts a nested array into a flat using a seperator. The prefix and
result parameter are used internally for performance reason and should
not be used

@param array $data
@param string $seperator
@param string $prefix
@param array $result
@return array
Converts a nested array into a flat using a seperator . The prefix and result parameter are used internally for performance reason and should not be used