Last active
April 25, 2025 14:01
-
-
Save vrana/eb84b267c3352b7e9f9adca888b8665b to your computer and use it in GitHub Desktop.
Sort ini.xml in phpdoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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