<crlf>
and then later pulling key:value pairs from that file using getsectionlist()
. It seems that when you use
writefile()
and your string contains <crlf>
, an invisible EOL character is appended everywhere <crlf>
was used, which breaks the functionality of getsectionlist()
. The function returns no results.Here's how I reproduce the issue...
First, I use
getsectionlist()
to get all the key:value pairs in every section of my current configuration.ini (using the default <crlf>
as the splitter between items)
Code: Select all
// Get all current key:value pairs from .ini
$sectionGeneralINI = getsectionlist("General", $childLauncherINI, "<crlf>");
$sectionAppsAdditionalINI = getsectionlist("AppsAdditional", $childLauncherINI, "<crlf>");
$sectionAppsRenameINI = getsectionlist("AppsRename", $childLauncherINI, "<crlf>");
$sectionAppsIconINI = getsectionlist("AppsIcon", $childLauncherINI, "<crlf>");
$sectionAppsHiddenINI = getsectionlist("AppsHidden", $childLauncherINI, "<crlf>");
regexreplace()
to insert each list into that template. The default <crlf> splitter from the last step assures that every item in the list is in a new line, like it should be for a .ini.Code: Select all
// Read template.ini and replace placeholders with key:value pairs
$templateINI = readfile($templateINI);
$templateINI = regexreplace($templateINI, "---------- GENERAL ----------", $sectionGeneralINI);
$templateINI = regexreplace($templateINI, "---------- APPSADDITIONAL ----------", $sectionAppsAdditionalINI);
$templateINI = regexreplace($templateINI, "---------- APPSRENAME ----------", $sectionAppsRenameINI);
$templateINI = regexreplace($templateINI, "---------- APPSICON ----------", $sectionAppsIconINI);
$templateINI = regexreplace($templateINI, "---------- APPSHIDDEN ----------", $sectionAppsHiddenINI);
Code: Select all
$writeStatus = writefile($childLauncherINI, "$templateINI", "o", "utf8");
<crlf>
splitter broke each item. When I next run my script and try to use getsectionlist()
to retrieve my saved settings, it returns no results. It won't return results until I remove each of the invisible characters from the file.I've attached a .ini that showcases these invisible characters. It was generated using the commands I outlined above. If you use
getsectionlist()
on it you'll return with no results, even though that section clearly exists. However, getkey()
still functions as normal.I'm assuming this is either a bug with
writefile()
or getsectionlist()
. If it's not, anyone know how I might use
writefile()
and not include these invisible line-ending characters? I've tried all the mode options, but I haven't been able to get it working.*** Update ***
I just tried using
setkey
and got the same issue; An invisible EOL character is added and using getsectionlist()
returns no results. After deleting the EOL character it works as expected.