The only thing I'm finding that actually switches it for the CLI is to reboot the Mac... I'm on Big Sur, and have put off updating to Monterey because when I updated to Big Sur, it broke MAMP Pro until there was a "compatible" version. I can't tell in my research if there's a Monterey-compatible MAMP Pro, but I'll be in rough waters if I can't use MAMP Pro on my websites.
Can someone advise me on this?! I'm on MAMP Pro version 6.4. I did change MAMP's Apache http.conf just to enable the CustomLog, then I added a site-specific CustomLog (VirtualHost), but I don't see how that could have broken CLI PHP version switching. I don't use Mac's Apache or PHP and I don't think anything hits it but I'm not sure, it came with Catalina. MAMP effectively changes /etc/hosts properly, though I don't think that has anything to do with CLI version, maybe I'm wrong. I don't think the macOS version has anything to do with it either since things were working without me having to update anything. Could the http.conf have anything to do with it?!
For macOS Monterey question, I can say the latest version of MAMP v6.6.1 is working in macOS Monterey 12.1. However, I've found some issues others may want to wait before upgrading:
1. Apache randomly stopping. (macOS Monterey) (plenty of resources available)
2. MAMP Pro hanging on quit when Launch Group Servers is set to System Startup
(This is more annoying than anything, and sometimes causes SQL to randomly quit on quitting MAMP.)
Now these could be just me so waiting to see who else reports.