sudo add-apt-repository ppa:ondrej/php
This repository contains all the released versions of PHP till date.
sudo apt update
sudo apt install php5.6
sudo apt install php7.0
sudo apt install php7.2
sudo update-alternatives --config php
sudo systemctl restart apache2
php -v