To figure out which packages are installed on an Ubuntu server, you can do:

apt list --installed

If you for example want to known which PHP 8.1 packages are installed, you can filter using grep:

$ sudo apt list --installed | grep -i php8.1

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

php8.1-bcmath/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-cli/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-common/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-curl/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-fpm/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-mbstring/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-mysql/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-opcache/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-readline/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-sqlite3/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-xml/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.1-zip/focal,now 8.1.7-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]