#!/bin/bash

function purge_php_packages {
    PACKAGES=(libapache2-mod-php php php-bcmath php-cli php-cli-prompt php-common php-composer-ca-bundle php-composer-semver php-composer-spdx-licenses php-curl php-fpm php-gd php-json php-json-schema php-mbstring php-mysql php-pear php-psr-log php-symfony-console php-symfony-debug php-symfony-filesystem php-symfony-finder php-symfony-polyfill-mbstring php-symfony-process php-xml php-zip php7.2 php7.2-bcmath php7.2-cli php7.2-common php7.2-curl php7.2-fpm php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml php7.2-zip)

    for PACKAGE in "${PACKAGES[@]}"
    do
        sudo apt-get purge -y $PACKAGE
    done
}

# Call the function
purge_php_packages

# Verify that all PHP packages have been removed
dpkg --get-selections | grep -i php
