Change Global (command line) php version (for laravel):
use this command :
sudo update-alternatives --config php
for more see link below :
https://bytexd.com/fix-laravel-return-type-of-illuminatesupportcollectionoffsetexistskey/
Change apache PHP version (for projects which you run with apache):
#(old php version)
sudo a2dismod php5
#(new php version )
sudo a2enmod php7.1
sudo systemctl restart apache2
https://superuser.com/questions/969861/phpinfo-and-php-v-shows-different-version-of-php