src/Type/Ini.php
public static function loopEncode($data, array $parent = array())
    {
        $resultString = '';
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                //subsection case
                //merge all the sections into one array...
                $sec = array_merge((array) $parent, (array) $key);
                //add section information to the output
                $resultString .= PHP_EOL . '[' . join('.', $sec) . ']' . PHP_EOL;
                //recursively traverse deeper
                $resultString .= self::loopEncode($value, $sec);
            } else {
                $resultString .= "$key = $value" . PHP_EOL;
            }
        }

        return $resultString;
    }
public static function loopEncode($data, array $parent = array())
    {
        $resultString = '';
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                //subsection case
                //merge all the sections into one array...
                $sec = array_merge((array) $parent, (array) $key);
                //add section information to the output
                $resultString .= PHP_EOL . '[' . join('.', $sec) . ']' . PHP_EOL;
                //recursively traverse deeper
                $resultString .= self::loopEncode($value, $sec);
            } else {
                $resultString .= "$key = $value" . PHP_EOL;
            }
        }

        return $resultString;
    }
public static function loopEncode ( $ data , array $ parent = array ( ) ) { $ resultString = '' ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { //subsection case //merge all the sections into one array... $ sec = array_merge ( ( array ) $ parent , ( array ) $ key ) ; //add section information to the output $ resultString .= PHP_EOL . '[' . join ( '.' , $ sec ) . ']' . PHP_EOL ; //recursively traverse deeper $ resultString .= self :: loopEncode ( $ value , $ sec ) ; } else { $ resultString .= "$key = $value" . PHP_EOL ; } } return $ resultString ; }
Method to look the data and encode it to ini format
@param  array $data   Data to encode
@param  array $parent Parent array, in case of recursive arrays
@return string
Method to look the data and encode it to ini format