diff --git a/src/SettingsWriter.php b/src/SettingsWriter.php index 182d29d..6bc51d7 100644 --- a/src/SettingsWriter.php +++ b/src/SettingsWriter.php @@ -81,18 +81,28 @@ class SettingsWriter foreach ($settings as $key => $value) { - fwrite( $this->handle, "$indent'$key' =>" ); + if (!is_numeric($key)) $key = "'$key'"; + fwrite( $this->handle, "$indent$key =>" ); // recursive walk through child arrays if ( is_array( $value ) ) { fwrite( $this->handle, "\n{$indent}[\n" ); - $this->write( $value ); + if (!empty($value)) $this->write( $value ); fwrite( $this->handle, "$indent]" ); } else { - fwrite( $this->handle, " '$value'" ); + switch (gettype($value)) + { + case 'NULL': + $value = 'null'; break; + case 'boolean': + $value = ($value) ? 'true' : 'false'; break; + case 'string': + $value = "'$value'"; break; + } + fwrite( $this->handle, " $value" ); } if ( next($settings) )