diff --git a/src/SettingsWriter.php b/src/SettingsWriter.php index 6bc51d7..d6fc41c 100644 --- a/src/SettingsWriter.php +++ b/src/SettingsWriter.php @@ -81,8 +81,8 @@ class SettingsWriter foreach ($settings as $key => $value) { - if (!is_numeric($key)) $key = "'$key'"; - fwrite( $this->handle, "$indent$key =>" ); + $stringKey = (is_numeric($key)) ? $key : "'$key'"; + fwrite( $this->handle, "$indent$stringKey =>" ); // recursive walk through child arrays if ( is_array( $value ) ) @@ -105,7 +105,7 @@ class SettingsWriter fwrite( $this->handle, " $value" ); } - if ( next($settings) ) + if ( array_key_last($settings) !== $key ) { fwrite( $this->handle, "," ); }