src/Arrays/Restructure.php
public static function makeFirstLevelArray($multilevelData)
    {
        $it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($multilevelData));
        $keyValueArr = [];
        foreach ($it as $k => $v) {

            $decoded = json_decode($v);
            if (!$decoded || is_int($decoded)) {
                throw new JsonException('Not json.');
            }

            if (is_array($decoded) || is_object($decoded)) {
                $nestedIt = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($decoded));
                foreach ($nestedIt as $nK => $nV) {
                    $keyValueArr[$nK] = $nV;
                }

                continue;
            }

            $keyValueArr[$k] = $v;
        }

        return $keyValueArr;
    }
public static function makeFirstLevelArray($multilevelData)
    {
        $it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($multilevelData));
        $keyValueArr = [];
        foreach ($it as $k => $v) {

            $decoded = json_decode($v);
            if (!$decoded || is_int($decoded)) {
                throw new JsonException('Not json.');
            }

            if (is_array($decoded) || is_object($decoded)) {
                $nestedIt = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($decoded));
                foreach ($nestedIt as $nK => $nV) {
                    $keyValueArr[$nK] = $nV;
                }

                continue;
            }

            $keyValueArr[$k] = $v;
        }

        return $keyValueArr;
    }
public static function makeFirstLevelArray ( $ multilevelData ) { $ it = new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ multilevelData ) ) ; $ keyValueArr = [ ] ; foreach ( $ it as $ k => $ v ) { $ decoded = json_decode ( $ v ) ; if ( ! $ decoded || is_int ( $ decoded ) ) { throw new JsonException ( 'Not json.' ) ; } if ( is_array ( $ decoded ) || is_object ( $ decoded ) ) { $ nestedIt = new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ decoded ) ) ; foreach ( $ nestedIt as $ nK => $ nV ) { $ keyValueArr [ $ nK ] = $ nV ; } continue ; } $ keyValueArr [ $ k ] = $ v ; } return $ keyValueArr ; }
Receive data and make first-level array
@param $multilevelData ; array || object
Receive data and make first - level array