Do you have multiple versions of PHP installed on Ubuntu 22.04? Youc an install a number of PHP version, check which are installed and switch between them easily through CLI.
For XAMPP, the following command will help you check the PHP version installed
sudo update-alternatives --config PHP
You can also set it to a version of your choice from the next step in the CLI