I created a script for easy switching PHP versions. This script can be used on Linux and macOS platforms. The script modifies the .env file and then stops and restarts the docker containers.
Check it out at https://gist.github.com/renekreijveld/66183c2bf308d393aa64137f13db3096
Installation instructions are in the comments below the script.