Great post about having multiple PHP version in your console: https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions.
Few snippets from the post:
brew tap shivammathur/php
brew install shivammathur/php/php@7.0
brew install shivammathur/php/php@7.1
brew install shivammathur/php/php@7.2
brew install shivammathur/php/php@7.3
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0
brew install shivammathur/php/php@8.1
brew install shivammathur/php/php@8.2
brew unlink php && brew link --overwrite --force php@7.3