First, unlink the version you want using the following command
brew unlink [email protected]
Then link your desired version using the following command
brew link [email protected]
Ref: https://daily-dev-tips.com/posts/installing-php-on-your-mac/