我試圖格式化,我下面創建使每一個名稱/值對自身行的文件,以打破輸出文件添加線過FWRITE
我敢肯定,這是很容易的,但我.ini文件根本沒有格式化換行符。我錯過了什麼?
function wpseTest()
{
$query = "SELECT option_name, option_value FROM wp_options where option_name like 'test|_%' escape '|' AND option_value > ''";
global $wpdb;
$matches = $wpdb->get_results($query);
$mySettings = '[settings]\r\n';
foreach ($matches as $result){
$mySettings .= $result->option_name;
$mySettings .= ' = ';
$mySettings .= $result->option_value;
$mySettings .= '\r\n';
}
$mySettingsFileLocation = WP_PLUGIN_DIR.'/test/settings-backup.ini';
$mySettingsFile = fopen($mySettingsFileLocation, 'w');
fwrite($mySettingsFile, $mySettings);
fclose($mySettingsFile);
}