First, you can select your preferred PHP version across the hosting account from cPanel as explained in this article.
You can select a different PHP version on each folder under your hosting account. This allows you to run different PHP scripts with different requirements on the same account.
To do so, use the following code in .htaccess file inside the folder in question:
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-httpd-alt-php73 </FilesMatch>
The above code will use PHP 7.3. To change the version, edit the last part of the second line of the code php73
If you want to run PHP 5.6 change php73
to php56
and if you want to run PHP7.4, change php73
to php74
and so on.
Note: This code will use alt-php provided by CloudLinux.