How to remove comments and empty lines from `php.ini`?

sed -i -r '/^[\s\t]*[#;]/d' php.ini
# 2024-07-28
# The previous command does not remove comments from lines indented with spaces (for an unknown reason).
# So I remove these comments using another command below.
sed -i -r '/^\s\+[#;]/d' php.ini
sed -i -r '/^\s*$/d' php.ini

See also: How to remove the # comments and empty lines from a configuration file?

For all files *.ini in the current folder and subfolders:

find . -name '*.ini' -type f -exec sed -i -r '/^[\s\t]*[#;]/d' {} +
# 2024-07-28
# The previous command does not remove comments from lines indented with spaces (for an unknown reason).
# So I remove these comments using another command below.
find . -name '*.ini' -type f -exec sed -i -r '/^\s+[#;]/d' {} +
find . -name '*.ini' -type f -exec sed -i -r '/^\s*$/d' {} +