Skip to content

Instantly share code, notes, and snippets.

@vrana
Last active April 25, 2025 14:01
Show Gist options
  • Save vrana/eb84b267c3352b7e9f9adca888b8665b to your computer and use it in GitHub Desktop.
Save vrana/eb84b267c3352b7e9f9adca888b8665b to your computer and use it in GitHub Desktop.
Sort ini.xml in phpdoc
<?php
foreach (array_merge(["appendices/ini.core.xml"], glob("reference/*/ini.xml")) as $filename) {
$file = file_get_contents($filename);
$file = preg_replace_callback('~(&Changelog;</entry>\s*</row>\s*</thead>\s*<tbody[^>]*>)(.*</row>)(\s*</tbody>)~sU', function ($match) {
preg_match_all('~.+</row>~sU', $match[2], $matches);
$rows = $matches[0];
usort($rows, function ($a, $b) {
return ltrim(strip_tags($a)) <=> ltrim(strip_tags($b));
});
return $match[1] . implode($rows) . $match[3];
}, $file);
file_put_contents($filename, $file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment