You could use these open source PHP Switch Scripts, which were designed specifically for use in Ubuntu 16.04 LTS.
https://github.com/rapidwebltd/php-switch-scripts
There is a setup.sh
script which installs all required dependencies for PHP 5.6, 7.0, 7.1 & 7.2. Once this is complete, you can just run one of the following switch scripts to change the PHP CLI and Apache 2 module version.
./switch-to-php-5.6.sh
./switch-to-php-7.0.sh
./switch-to-php-7.1.sh
./switch-to-php-7.2.sh